defineModel
defineModel<
T,PK,UNIQUE,INDEX>(tableName,cls,opts?):ModelClass<StaticMembers<T>,FieldsOf<T>,PKArgs<FieldsOf<T>,PK>,PublicIndexSpecs<UNIQUE>,PublicIndexSpecs<INDEX>>
Defined in: .work/repos/edinburgh/src/models.ts:510
Register a model class with the Edinburgh ORM system.
Converts a plain class into a fully-featured model with database persistence, typed fields, primary key access, and optional secondary and unique indexes.
Type Parameters
Section titled “Type Parameters”T extends () => any
PK extends string | readonly keyof FieldsOf<T> & string[]
UNIQUE
Section titled “UNIQUE”UNIQUE extends Record<string, IndexSpec<T>>
INDEX extends Record<string, IndexSpec<T>>
Parameters
Section titled “Parameters”tableName
Section titled “tableName”string
The database table name for this model.
T
A plain class whose properties use E.field().
Registration options.
PK
Primary key field name or array of field names.
unique?
Section titled “unique?”UNIQUE
Named unique index specifications (field name, field array, or compute function).
index?
Section titled “index?”INDEX
Named secondary index specifications (field name, field array, or compute function).
override?
Section titled “override?”boolean
Replace a previous model with the same table name.
Returns
Section titled “Returns”ModelClass<StaticMembers<T>, FieldsOf<T>, PKArgs<FieldsOf<T>, PK>, PublicIndexSpecs<UNIQUE>, PublicIndexSpecs<INDEX>>
The enhanced model constructor.