Optional
Private
Internal
_autoThis attribute was added by sequelize. Do not use!
Optional
allowIf false, the column will have a NOT NULL constraint, and a not null validation will be run before an instance is saved.
true
Optional
autoIs this field an auto increment field
Optional
autoIf this field is a Postgres auto increment field, use Postgres GENERATED BY DEFAULT AS IDENTITY
instead of SERIAL
. Postgres 10+ only.
Optional
commentComment to add on the column in the database.
Optional
defaultA literal default value, a JavaScript function, or an SQL function (using fn)
Optional
fieldThe name of the column.
If no value is provided, Sequelize will use the name of the attribute (in snake_case if underscored is true)
Optional
fieldAlias of name.
Optional
nameThe name of the foreign key attribute.
Not to be confused with field which controls the name of the foreign key Column.
Optional
onWhat should happen when the referenced key is deleted. One of CASCADE, RESTRICT, SET DEFAULT, SET NULL or NO ACTION
Optional
onWhat should happen when the referenced key is updated. One of CASCADE, RESTRICT, SET DEFAULT, SET NULL or NO ACTION
Optional
primaryIf true, this attribute will be marked as primary key
Optional
referencesMakes this attribute a foreign key. You typically don't need to use this yourself, instead use associations.
Setting this value to a string equivalent to setting it to { model: 'myString' }
.
Optional
typeOptional
uniqueIf true, the column will get a unique constraint. If a string is provided, the column will be part of a composite unique index. If multiple columns have the same string, they will be part of the same unique index
Optional
validateAn object of validations to execute for this column every time the model is saved. Can be either the
name of a validation provided by validator.js, a validation function provided by extending validator.js
(see the
DAOValidator
property for more details), or a custom validation function. Custom validation functions
are called with the value of the field, and can possibly take a second callback argument, to signal that
they are asynchronous. If the validator is sync, it should throw in the case of a failed validation, it
it is async, the callback should be called with the error text.
Optional
valuesUsage in object notation
class MyModel extends Model {}
MyModel.init({
states: {
type: DataTypes.ENUM,
values: ['active', 'pending', 'deleted']
}
}, { sequelize })
Optional
getProvide a custom getter for this column. Use getDataValue to access the underlying values.
Optional
setProvide a custom setter for this column. Use setDataValue to access the underlying values.
Generated using TypeDoc
Foreign Key Options