Optional
charsetThe charset to use for the model
Optional
collateThe collation for model's table
Optional
commentA comment for the table.
MySQL, PG only.
Optional
createdOverride the name of the createdAt attribute if a string is provided, or disable it if false. ModelOptions.timestamps must be true.
Not affected by underscored setting.
Optional
defaultDefine the default search scope to use for this model. Scopes have the same form as the options passed to find / findAll.
See https://sequelize.org/docs/v7/other-topics/scopes/ to learn more about scopes.
Optional
deletedOverride the name of the deletedAt attribute if a string is provided, or disable it if false. ModelOptions.timestamps must be true. ModelOptions.paranoid must be true.
Not affected by underscored setting.
Optional
engineThe name of the database storage engine to use (e.g. MyISAM, InnoDB).
MySQL, MariaDB only.
Optional
freezeIf true, sequelize will use the name of the Model as-is as the name of the SQL table. If false, the name of the table will be pluralised (and snake_cased if ModelOptions.underscored is true).
This option has no effect if ModelOptions.tableName is set.
false
Optional
hasIndicates if the model's table has a trigger associated with it.
false
Optional
hooksAdd hooks to the model. Hooks will be called before and after certain operations.
This can also be done through Model.addHook, or the individual hook methods such as Model.afterBulkCreate. Each property can either be a function, or an array of functions.
Optional
indexesIndexes for the provided database table
Optional
initialSet the initial AUTO_INCREMENT value for the table in MySQL.
Optional
modelThe name of the model.
If not set, the name of the class will be used instead. You should specify this option if you are going to minify your code in a way that may mangle the class name.
Not inherited.
Optional
nameAn object with two attributes, singular
and plural
, which are used when this model is associated to others.
Not inherited.
Optional
noSequelize will automatically add a primary key called id
if no
primary key has been added manually.
Set to false to disable adding that primary key.
false
Optional
omitDon't persist null values. This means that all columns with null values will not be saved.
false
Optional
paranoidIf true, calling Model.destroy will not delete the model, but will instead set a deletedAt
timestamp.
This options requires ModelOptions.timestamps to be true.
The deletedAt
column can be customized through ModelOptions.deletedAt.
false
Optional
schemaThe database schema in which this table will be located.
Optional
schemaOptional
scopesMore scopes, defined in the same way as ModelOptions.defaultScope above. See Model.scope for more information about how scopes are defined, and what you can do with them.
See https://sequelize.org/docs/v7/other-topics/scopes/ to learn more about scopes.
Optional
tableThe name of the table in SQL.
The {@link ModelOptions.modelName}, pluralized,
unless freezeTableName is true, in which case it uses model name
verbatim.
Not inherited.
Optional
timestampsAdds createdAt and updatedAt timestamps to the model.
true
Optional
underscoredIf true, Sequelize will snake_case the name of columns that do not have an explicit value set (using AttributeOptions.field). The name of the table will also be snake_cased, unless ModelOptions.tableName is set, or ModelOptions.freezeTableName is true.
false
Optional
updatedOverride the name of the updatedAt attribute if a string is provided, or disable it if false. ModelOptions.timestamps must be true.
Not affected by underscored setting.
Optional
validateAn object of model wide validations. Validations have access to all model values via this
. If the
validator function takes an argument, it is assumed to be async, and is called with a callback that
accepts an optional error.
Custom validation functions run on all instances of the model.
Optional
versionEnable optimistic locking. When enabled, sequelize will add a version count attribute to the model and throw an OptimisticLockingError error when stale instances are saved.
version
.false
Options for model definition.
Used by Sequelize.define, Model.init, and the decorators-legacy.Table decorator.
See
https://sequelize.org/docs/v7/core-concepts/model-basics/