Skip to content

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.

T extends () => any

PK extends string | readonly keyof FieldsOf<T> & string[]

UNIQUE extends Record<string, IndexSpec<T>>

INDEX extends Record<string, IndexSpec<T>>

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

Named unique index specifications (field name, field array, or compute function).

INDEX

Named secondary index specifications (field name, field array, or compute function).

boolean

Replace a previous model with the same table name.

ModelClass<StaticMembers<T>, FieldsOf<T>, PKArgs<FieldsOf<T>, PK>, PublicIndexSpecs<UNIQUE>, PublicIndexSpecs<INDEX>>

The enhanced model constructor.