Provide functions that are added to the model (Model). If you override methods provided by sequelize,
you can access the original method using this.constructor.prototype
, e.g.
this.constructor.prototype.find.apply(this, arguments)
Finaly you can specify a comment for the table in MySQL and PG
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.
Define the default search scope to use for this model. Scopes have the same form as the options passed to find / findAll.
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.
You can also change the database engine, e.g. to MyISAM. InnoDB is the default.
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.
Provide getter functions that work like those defined per column. If you provide a getter method with the same name as a column, it will be used to access the value of that column. If you provide a name that does not match a column, this function will act as a virtual getter, that can fetch multiple other values
Indicates if the model's table has a trigger associated with it. Default false.
An object of hook function that are called before and after certain lifecycle events. The possible hooks are: beforeValidate, afterValidate, beforeBulkCreate, beforeBulkDestroy, beforeBulkUpdate, beforeCreate, beforeDestroy, beforeUpdate, afterCreate, afterDestroy, afterUpdate, afterBulkCreate, afterBulkDestory and afterBulkUpdate. See Hooks for more information about hook functions and their signatures. Each property can either be a function, or an array of functions.
Indexes for the provided database table
Set the initial AUTO_INCREMENT value for the table in MySQL.
Provide functions that are added to each instance (DAO). If you override methods provided by sequelize,
you can access the original method using this.constructor.super_.prototype
, e.g.
this.constructor.super_.prototype.toJSON.apply(this, arguments)
An object with two attributes, singular
and plural
, which are used when this model is associated to
others.
Don't persits null values. This means that all columns with null values will not be saved.
Calling destroy will not delete the model, but instead set a deletedAt timestamp if this is true. Needs timestamps=true to work. Default false.
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
Provide setter functions that work like those defined per column. If you provide a setter method with the same name as a column, it will be used to update the value of that column. If you provide a name that does not match a column, this function will act as a virtual setter, that can act on and set other values, but will not be persisted
Defaults to pluralized model name, unless freezeTableName is true, in which case it uses model name verbatim
Adds createdAt and updatedAt timestamps to the model. Default true.
Converts all camelCased columns to underscored if true. Default false.
Converts camelCased model names to underscored tablenames if true. Default false.
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.
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.
Generated using TypeDoc
Options for model definition
Sequelize.define