Deferrable()
-> object
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
});
INITIALLY_DEFERRED()
A property that will defer constraints checks to the end of transactions.
INITIALLY_IMMEDIATE()
A property that will trigger the constraint checks immediately
NOT()
A property that will 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(constraints)
A property that will trigger an additional query at the beginning of a transaction which sets the constraints to deferred.
Params:
Name | Type | Description |
---|---|---|
constraints | Array | An array of constraint names. Will defer all constraints by default. |
SET_IMMEDIATE(constraints)
A property that will trigger an additional query at the beginning of a transaction which sets the constraints to immediately.
Params:
Name | Type | Description |
---|---|---|
constraints | Array | An 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