Static
addStatic
afterStatic
afterStatic
afterStatic
afterStatic
afterStatic
afterStatic
afterStatic
afterA hook that is run after a find (select) query
Static
afterStatic
afterStatic
afterA hook that is run at the end of Model.sync
Static
afterStatic
afterStatic
afterStatic
beforeStatic
beforeStatic
beforeStatic
beforeStatic
beforeStatic
beforeA hook that is run at the start of Model.count
Static
beforeStatic
beforeStatic
beforeA hook that is run before a find (select) query
Static
beforeA hook that is run before a find (select) query, after any { include: {all: ...} }
options are expanded
use beforeFind
instead
Static
beforeA hook that is run before a find (select) query, after all option have been normalized
use beforeFind
instead
Static
beforeStatic
beforeStatic
beforeA hook that is run at the start of Model.sync
Static
beforeStatic
beforeStatic
beforeStatic
hasStatic
hasStatic
removeStatic
runStatic
validationuse modelDefinition's ModelDefinition#rawAttributes or ModelDefinition#attributes instead.
A reference to the sequelize instance.
Private
Static
_indexesStatic
associationsAn object hash from alias to the association object
Static
fieldPrivate
A mapping of column name to attribute name
Static
fieldStatic
hooksStatic
modelReturns the model definition of this model. The model definition contains all metadata about this model.
Static
modelStatic
optionsThe options that the model was initialized with
Static
primaryThe name of the primary key attribute (on the JS side).
This property doesn't work for composed primary keys. Use primaryKeyAttributes instead.
Static
primaryThe name of the primary key attributes (on the JS side).
use modelDefinition.
Static
primaryThe column name of the primary key.
don't use this. It doesn't work with composite PKs. It may be removed in the future to reduce duplication. Use the. Use Model.primaryKeys instead.
Static
primaryLike Model.rawAttributes, but only includes attributes that are part of the Primary Key.
Static
queryStatic
queryStatic
rawuse modelDefinition's ModelDefinition#rawAttributes or ModelDefinition#attributes instead.
Static
sequelizeA reference to the sequelize instance.
Accessing this property throws if the model has not been registered with a Sequelize instance yet.
Static
tableStatic
tableStatic
tableThe name of the database table
use modelDefinition or table.
Static
uniqueUnique indexes that can be declared as part of a CREATE TABLE query.
prefer using getIndexes, this will eventually be removed.
Static
_UNSTABLE_Works like the Model#destroy instance method, but is capable of deleting multiple instances in one query.
Unlike Model.destroy, this method takes instances, not a where
option.
The instances to delete.
Optional
options: DestroyOptions<Attributes<M>>Options.
Static
assertStatic
getStatic
getGet the table name of the model, taking schema into account. The method will an object with tableName
, schema
and delimiter
properties.
use modelDefinition or table.
Static
initInitialize a model, representing a table in the DB, with attributes and options.
The table columns are defined by the hash that is given as the first argument. Each attribute of the hash represents a column.
An object, where each attribute is a column of the table. Each column can be either a DataType, a string or a type-description object.
These options are merged with the default define options provided to the Sequelize constructor
Project.init({
columnA: {
type: DataTypes.BOOLEAN,
validate: {
is: ['[a-z]','i'], // will only allow letters
max: 23, // only allow values <= 23
isIn: {
args: [['en', 'zh']],
msg: "Must be English or Chinese"
}
},
field: 'column_a'
// Other attributes here
},
columnB: DataTypes.STRING,
columnC: 'MY VERY OWN COLUMN TYPE'
}, {sequelize})
sequelize.models.modelName // The model will now be available in models under the class name
Static
isStatic
refreshRefreshes the Model's attribute definition.
use modelDefinition.
This is a temporary class used to progressively migrate the Model class to TypeScript by slowly moving its functions here. Always use Model instead.