moonbitstack/moonorm/schema does not have a README file
pub(all) struct Column {
name : String
col_type : ColumnType
primary_key : Bool
autoincrement : Bool
nullable : Bool
unique : Bool
default : String?
checks : Array[String]
references : (String, String)?
on_delete : String?
on_update : String?
}pub(all) enum ColumnType {
IntType
BigIntType
TextType
RealType
BlobType
BoolType
VarcharType(Int)
NumericType
DateTimeType
DateType
TimeType
UuidType
JsonType
UserType(CustomColumnType)
} derive(Eq)pub(all) enum LoadStrategy {
SubqueryLoad
JoinedLoad
RaiseLoad
}fn[S, T] ManyToMany::batch_sql(self : ManyToMany[S, T], sources : Array[S]) -> (String, Array[Value])fn[S, T] ManyToMany::joined_sql(self : ManyToMany[S, T], sources : Array[S]) -> (String, Array[Value])pub struct Model[T] {
table : String
columns : Array[Column]
from_row : (Row) -> T raise DbError
to_columns : (T) -> Array[(String, Value)]
indexes : Array[Index]
filter : Array[(String, Value)]
joins : Array[(String, String)]
projection : Array[String]
parent : (String, Array[String], String)?
ident : Map[Int, Map[String, T]]
}Model::from_fields(
"hero",
[
field("id", IntType, primary_key=true, h => h.id),
field("name", TextType, nullable=false, h => h.name),
],
r => { id: r.read(0), name: r.read(1) },
)fn column(name : String, col_type : ColumnType, primary_key? : Bool, autoincrement? : Bool, nullable? : Bool, unique? : Bool, default? : String, checks? : Array[String], references? : (String, String), on_delete? : String, on_update? : String) -> Columnfn drop_column_sql(table : String, name : String) -> Stringfn drop_table_sql(name : String, if_exists? : Bool) -> Stringfn[T, V : ToValue] field(name : String, col_type : ColumnType, encode : (T) -> V, primary_key? : Bool, autoincrement? : Bool, nullable? : Bool, unique? : Bool, default? : String, checks? : Array[String], references? : (String, String), on_delete? : String, on_update? : String) -> Field[T]fn[S, T, V : ToValue] many_to_many(target : Model[T], junction~ : String, source_fk~ : String, target_fk~ : String, target_key~ : String, source_key~ : (S) -> V) -> ManyToMany[S, T]fn rename_column_sql(table : String, from : String, to : String) -> Stringfn rename_table_sql(from : String, to : String) -> StringInstall
Download zipAn ORM and SQL toolkit for MoonBit.