Deferrable() -> object

View code

A collection of properties related to deferrable constraints. It can be used tomake foreign key constraints deferrable and to set the constraints within atransaction. This is only supported in PostgreSQL.

The foreign keys can be configured like this. It will create a foreign keythat will check the constraints immediately when the data was inserted.

  1. sequelize.define('Model', {
  2. foreign_id: {
  3. type: Sequelize.INTEGER,
  4. references: {
  5. model: OtherModel,
  6. key: 'id',
  7. deferrable: Sequelize.Deferrable.INITIALLY_IMMEDIATE
  8. }
  9. }
  10. });

The constraints can be configured in a transaction like this. It willtrigger a query once the transaction has been started and set the constraintsto be checked at the very end of the transaction.

  1. sequelize.transaction({
  2. deferrable: Sequelize.Deferrable.SET_DEFERRED
  3. });

INITIALLY_DEFERRED()

View code

A property that will defer constraints checks to the end of transactions.


INITIALLY_IMMEDIATE()

View code

A property that will trigger the constraint checks immediately


NOT()

View code

A property that will set the constraints to not deferred. This isthe default in PostgreSQL and it make it impossible to dynamicallydefer the constraints within a transaction.


SET_DEFERRED(constraints)

View code

A property that will trigger an additional query at the beginning of atransaction which sets the constraints to deferred.

Params:

NameTypeDescription
constraintsArrayAn array of constraint names. Will defer all constraints by default.

SET_IMMEDIATE(constraints)

View code

A property that will trigger an additional query at the beginning of atransaction which sets the constraints to immediately.

Params:

NameTypeDescription
constraintsArrayAn array of constraint names. Will defer all constraints by default.

This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on IRC, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see JSDoc and dox