StaticaddStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticafterStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStaticbeforeStatichasStatichasStaticremoveStaticrunStaticvalidationuse modelDefinition's ModelDefinition#rawAttributes or ModelDefinition#attributes instead.
A reference to the sequelize instance.
StaticassociationsAn object hash from alias to the association object
StaticfieldStatichooksStaticmodelReturns the model definition of this model. The model definition contains all metadata about this model.
StaticmodelStaticoptionsThe options that the model was initialized with
StaticprimaryThe name of the primary key attribute (on the JS side).
This property doesn't work for composed primary keys. Use primaryKeyAttributes instead.
StaticprimaryThe name of the primary key attributes (on the JS side).
use modelDefinition.
StaticprimaryThe 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.
StaticprimaryLike Model.rawAttributes, but only includes attributes that are part of the Primary Key.
StaticqueryStaticqueryStaticrawuse modelDefinition's ModelDefinition#rawAttributes or ModelDefinition#attributes instead.
StaticsequelizeA reference to the sequelize instance.
Accessing this property throws if the model has not been registered with a Sequelize instance yet.
StatictableStatictableStatictableStaticuniqueUnique 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.
Optionaloptions: DestroyOptions<Attributes<M>>Options.
StaticassertStaticfindSearch for a single instance by its primary key.
This applies LIMIT 1, only a single instance will be returned.
Returns the model with the matching primary key. If not found, returns null or throws an error if FindOptions.rejectOnEmpty is set.
Search for a single instance by its primary key.
This applies LIMIT 1, only a single instance will be returned.
Returns the model with the matching primary key. If not found, returns null or throws an error if FindOptions.rejectOnEmpty is set.
Search for a single instance by its primary key.
This applies LIMIT 1, only a single instance will be returned.
Returns the model with the matching primary key. If not found, returns null or throws an error if FindOptions.rejectOnEmpty is set.
Search for a single instance by its primary key.
This applies LIMIT 1, only a single instance will be returned.
Returns the model with the matching primary key. If not found, returns null or throws an error if FindOptions.rejectOnEmpty is set.
Optionaloptions: FindByPkOptions<M>StaticgetStaticgetGet 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.
StaticinitInitialize 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
StaticisStaticrefresh
This is a temporary class used to progressively migrate the Model class to TypeScript by slowly moving its functions here. Always use Model instead.