Static Public Summary | ||
---|---|---|
public | DataTypes: * A convenience class holding commonly used data types. | |
public | Deferrable: * A collection of properties related to deferrable constraints. | |
public | IndexHints: * An enum of index hints to be used in mysql for querying with index hints | |
public | Op: {"eq": *, "ne": *, "gte": *, "gt": *, "lte": *, "lt": *, "not": *, "is": *, "in": *, "notIn": *, "like": *, "notLike": *, "iLike": *, "notILike": *, "startsWith": *, "endsWith": *, "substring": *, "regexp": *, "notRegexp": *, "iRegexp": *, "notIRegexp": *, "between": *, "notBetween": *, "overlap": *, "contains": *, "contained": *, "adjacent": *, "strictLeft": *, "strictRight": *, "noExtendRight": *, "noExtendLeft": *, "and": *, "or": *, "any": *, "all": *, "values": *, "col": *, "placeholder": *, "join": *} Operator symbols to be used when querying data | |
public | QueryTypes: * An enum of query types used by | |
public | TableHints: * An enum of table hints to be used in mssql for querying with table hints |
A convenience class holding commonly used data types. The data types are used when defining a new model using Sequelize.define
, like this:
sequelize.define('model', {
column: DataTypes.INTEGER
})
When defining a model you can just as easily pass a string as type, but often using the types defined here is beneficial. For example, using DataTypes.BLOB
, mean that that column will be returned as an instance of Buffer
when being fetched by sequelize.
To provide a length for the data type, you can invoke it like a function: INTEGER(2)
Some data types have special properties that can be accessed in order to change the data type. For example, to get an unsigned integer with zerofill you can do DataTypes.INTEGER.UNSIGNED.ZEROFILL
. The order you access the properties in do not matter, so DataTypes.INTEGER.ZEROFILL.UNSIGNED
is fine as well.
INTEGER
, BIGINT
, FLOAT
, DOUBLE
, REAL
, DECIMAL
) expose the properties UNSIGNED
and ZEROFILL
CHAR
and STRING
types expose the BINARY
propertyThree of the values provided here (NOW
, UUIDV1
and UUIDV4
) are special default values, that should not be used to define types. Instead they are used as shorthands for defining default values. For example, to get a uuid field with a default value generated following v1 of the UUID standard:
sequelize.define('model', {
uuid: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV1,
primaryKey: true
}
})
There may be times when you want to generate your own UUID conforming to some other algorithm. This is accomplished using the defaultValue property as well, but instead of specifying one of the supplied UUID types, you return a value from a function.
sequelize.define('model', {
uuid: {
type: DataTypes.UUID,
defaultValue: function() {
return generateMyId()
},
primaryKey: true
}
})
A collection of properties related to deferrable constraints. It can be used to make foreign key constraints deferrable and to set the constraints within a transaction. This is only supported in PostgreSQL.
The foreign keys can be configured like this. It will create a foreign key that will check the constraints immediately when the data was inserted.
sequelize.define('Model', {
foreign_id: {
type: Sequelize.INTEGER,
references: {
model: OtherModel,
key: 'id',
deferrable: Sequelize.Deferrable.INITIALLY_IMMEDIATE
}
}
});
The constraints can be configured in a transaction like this. It will trigger a query once the transaction has been started and set the constraints to be checked at the very end of the transaction.
sequelize.transaction({
deferrable: Sequelize.Deferrable.SET_DEFERRED
});
Name | Type | Attribute | Description |
---|---|---|---|
INITIALLY_DEFERRED | * |
Defer constraints checks to the end of transactions. | |
INITIALLY_IMMEDIATE | * |
Trigger the constraint checks immediately | |
NOT | * |
Set the constraints to not deferred. This is the default in PostgreSQL and it make it impossible to dynamically defer the constraints within a transaction. | |
SET_DEFERRED | * | ||
SET_IMMEDIATE | * |
An enum of index hints to be used in mysql for querying with index hints
Name | Type | Attribute | Description |
---|---|---|---|
USE | * | ||
FORCE | * | ||
IGNORE | * |
Operator symbols to be used when querying data
Name | Type | Attribute | Description |
---|---|---|---|
eq | * | ||
ne | * | ||
gte | * | ||
gt | * | ||
lte | * | ||
lt | * | ||
not | * | ||
is | * | ||
in | * | ||
notIn | * | ||
like | * | ||
notLike | * | ||
iLike | * | ||
notILike | * | ||
startsWith | * | ||
endsWith | * | ||
substring | * | ||
regexp | * | ||
notRegexp | * | ||
iRegexp | * | ||
notIRegexp | * | ||
between | * | ||
notBetween | * | ||
overlap | * | ||
contains | * | ||
contained | * | ||
adjacent | * | ||
strictLeft | * | ||
strictRight | * | ||
noExtendRight | * | ||
noExtendLeft | * | ||
and | * | ||
or | * | ||
any | * | ||
all | * | ||
values | * | ||
col | * | ||
placeholder | * | ||
join | * |
An enum of query types used by sequelize.query
Name | Type | Attribute | Description |
---|---|---|---|
SELECT | * | ||
INSERT | * | ||
UPDATE | * | ||
BULKUPDATE | * | ||
BULKDELETE | * | ||
DELETE | * | ||
UPSERT | * | ||
VERSION | * | ||
SHOWTABLES | * | ||
SHOWINDEXES | * | ||
DESCRIBE | * | ||
RAW | * | ||
FOREIGNKEYS | * | ||
SHOWCONSTRAINTS | * |
An enum of table hints to be used in mssql for querying with table hints
Name | Type | Attribute | Description |
---|---|---|---|
NOLOCK | * | ||
READUNCOMMITTED | * | ||
UPDLOCK | * | ||
REPEATABLEREAD | * | ||
SERIALIZABLE | * | ||
READCOMMITTED | * | ||
TABLOCK | * | ||
TABLOCKX | * | ||
PAGLOCK | * | ||
ROWLOCK | * | ||
NOWAIT | * | ||
READPAST | * | ||
XLOCK | * | ||
SNAPSHOT | * | ||
NOEXPAND | * |
Copyright © 2014–present Sequelize contributors
Licensed under the MIT License.
https://sequelize.org/master/variable/index.html