model<S extends Record> function
- String table,
- S fields, {
- Object primaryKey(
- S
- List<
Object> uniqueKeys(- S
- List<
IndexDefinition> indexes(- S
- Record relations(
- S
- List<
CheckDefinition> ? checks,
Defines a model using named column declarations and local constraints.
Declare a public final employee = model('employees', (...)). The named
Record's shape supplies the types in local key, index and relation selectors.
Add an explicit Model type to break self-reference or mutual-reference
inference cycles; selector field types are preserved in either form.
Select keys with a direct column or an ordered positional Record of columns.
Selectors must be arrow expressions. relations returns a named Record of
references/referencedBy declarations; other collections are literal lists.
Every field of fields must be a column declaration, checked by generation.
Callbacks are not executed and do not register mutable runtime metadata.
Generate and import the client to query typed rows.
Implementation
Model model<S extends Record>(
String table,
S fields, {
Object Function(S)? primaryKey,
List<Object> Function(S)? uniqueKeys,
List<IndexDefinition> Function(S)? indexes,
Record Function(S)? relations,
List<CheckDefinition>? checks,
}) => Model._(table, fields);