Interface TableOptions<M>

Type Parameters

  • M extends Model = Model

Hierarchy

  • ModelOptions<M>
    • TableOptions

Properties

charset?: string
collate?: string
comment?: string

Finaly you can specify a comment for the table in MySQL and PG

createdAt?: string | boolean

Override the name of the createdAt column if a string is provided, or disable it if false. Timestamps must be true. Not affected by underscored setting.

defaultScope?: FindOptions<Attributes<M>>

Define the default search scope to use for this model. Scopes have the same form as the options passed to find / findAll.

deletedAt?: string | boolean

Override the name of the deletedAt column if a string is provided, or disable it if false. Timestamps must be true. Not affected by underscored setting.

engine?: string

You can also change the database engine, e.g. to MyISAM. InnoDB is the default.

freezeTableName?: boolean

If freezeTableName is true, sequelize will not try to alter the DAO name to get the table name. Otherwise, the dao name will be pluralized. Default false.

getterMethods?: ModelGetterOptions<M>

Allows defining additional getters that will be available on model instances.

hasTrigger?: boolean

Indicates if the model's table has a trigger associated with it. Default false.

hooks?: Partial<ModelHooks<M, Attributes<M>>>

An object of hook function that are called before and after certain lifecycle events. See Hooks for more information about hook functions and their signatures. Each property can either be a function, or an array of functions.

indexes?: readonly IndexesOptions[]

Indexes for the provided database table

initialAutoIncrement?: string

Set the initial AUTO_INCREMENT value for the table in MySQL.

modelName?: string
name?: ModelNameOptions

An object with two attributes, singular and plural, which are used when this model is associated to others.

omitNull?: boolean

Don't persits null values. This means that all columns with null values will not be saved.

paranoid?: boolean

Calling destroy will not delete the model, but instead set a deletedAt timestamp if this is true. Needs timestamps=true to work. Default false.

schema?: string
scopes?: ModelScopeOptions<Attributes<M>>

More scopes, defined in the same way as defaultScope above. See Model.scope for more information about how scopes are defined, and what you can do with them

setterMethods?: ModelSetterOptions<M>

Allows defining additional setters that will be available on model instances.

tableName?: string

Default

pluralized model name, unless freezeTableName is true, in which case it uses model name
verbatim
timestamps?: boolean

Adds createdAt and updatedAt timestamps to the model. Default true.

underscored?: boolean

Converts all camelCased columns to underscored if true. Default false.

updatedAt?: string | boolean

Override the name of the updatedAt column if a string is provided, or disable it if false. Timestamps must be true. Not affected by underscored setting.

validate?: ModelValidateOptions

An object of model wide validations. Validations have access to all model values via this. If the validator function takes an argument, it is asumed to be async, and is called with a callback that accepts an optional error.

version?: string | boolean

Enable optimistic locking. When enabled, sequelize will add a version count attribute to the model and throw an OptimisticLockingError error when stale instances are saved. Set to true or a string with the attribute name you want to use to enable.

whereMergeStrategy?: "overwrite" | "and"

Specify the scopes merging strategy (default 'overwrite'). Valid values are 'and' and 'overwrite'. When the 'and' strategy is set, scopes will be grouped using the Op.and operator. For instance merging scopes containing { where: { myField: 1 }} and { where: { myField: 2 }} will result in { where: { [Op.and]: [{ myField: 1 }, { myField: 2 }] } }. When the 'overwrite' strategy is set, scopes containing the same attribute in a where clause will be overwritten by the lastly defined one. For instance merging scopes containing { where: { myField: 1 }} and { where: { myField: 2 }} will result in { where: { myField: 2 } }.

Default

false

Generated using TypeDoc