ModelOptions

interface ModelOptions {
    indexes?: IndexesDefinition;
    int8id?: boolean;
    parent?: Model;
    primaryKey?: string;
    sync?: boolean;
    tableName?: string;
}

Specifies the options for the Model.

ModelOptions.indexes

  • default: {}

Defines the indexes of the Model. See IndexesDefinition for details.

ModelOptions.int8id

  • default: false

If true, the implicit id attribute used as primary key is of type INT8, see Data types for details.

Note

This option conflicts with ModelOptions.parent and ModelOptions.primaryKey ones.

ModelOptions.parent

  • default: undefined

If provided, defines the parent of the Model. This reflects both on classes hierarchy at JavaScript level and on tables hierarchy at database level. The primary key is inherited as well: neither an implicit id attribute is added nor can be specified through ModelOptions.primaryKey option.

Warning

Not all the database engine specialized packages may support this option.

Note

This option conflicts with ModelOptions.int8id and ModelOptions.primaryKey ones.

ModelOptions.primaryKey

  • default: undefined

The value must be the name of an attribute. If provided, defines the primary key of the Model. The implicit id attribute is not added to the Model.

Note

This option conflicts with ModelOptions.int8id and ModelOptions.parent ones.

ModelOptions.sync

If false, Sedentary does not sync the table associated to the Model, it simply checks if the Model is compliant with the table at database level.

ModelOptions.tableName

  • default: undefined

If not provided, the name of the table is tha name of the Model (i.e. the name argument of the sedentary.model() call), otherwise it overrides the default table name.