W3cubDocs

/Sequelize
Static Public Summary
public

A convenience class holding commonly used data types.

public

A collection of properties related to deferrable constraints.

public

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

An enum of query types used by sequelize.query

public

An enum of table hints to be used in mssql for querying with table hints

Static Public

public DataTypes: * source

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.

  • All number types (INTEGER, BIGINT, FLOAT, DOUBLE, REAL, DECIMAL) expose the properties UNSIGNED and ZEROFILL
  • The CHAR and STRING types expose the BINARY property

Three 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
  }
})

public Deferrable: * source

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
});

Properties:

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 *

public IndexHints: * source

An enum of index hints to be used in mysql for querying with index hints

Properties:

Name Type Attribute Description
USE *
FORCE *
IGNORE *

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": *} source

Operator symbols to be used when querying data

Properties:

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 *

public QueryTypes: * source

An enum of query types used by sequelize.query

Properties:

Name Type Attribute Description
SELECT *
INSERT *
UPDATE *
BULKUPDATE *
BULKDELETE *
DELETE *
UPSERT *
VERSION *
SHOWTABLES *
SHOWINDEXES *
DESCRIBE *
RAW *
FOREIGNKEYS *
SHOWCONSTRAINTS *

public TableHints: * source

An enum of table hints to be used in mssql for querying with table hints

Properties:

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