Sequelize: Add to the Table's options to support Optimistic Locking.

This commit is contained in:
Izik Lisbon
2017-07-14 20:21:08 -07:00
parent ababb9cd46
commit 7225bdcae6
2 changed files with 20 additions and 1 deletions

View File

@@ -5094,6 +5094,12 @@ declare namespace sequelize {
*/
validate?: DefineValidateOptions;
/**
* Enable optimistic locking. When enabled, sequelize will add a version count attribute
* to the model and throw an OptimisticLockingError error when stale instances are saved.
* Set to true or a string with the attribute name you want to use to enable.
*/
version?: boolean | string;
}
/**

View File

@@ -1572,7 +1572,20 @@ s.define( 'test', {
underscored : true,
freezeTableName : true
} );
s.define( 'testBooeanVersionOption', {
version : {
type : Sequelize.INTEGER,
}
}, {
version: true
} );
s.define( 'testStringVersionOption', {
nameOfOptimisticLockColumn : {
type : Sequelize.INTEGER,
}
}, {
version: "nameOfOptimisticLockColumn"
} );
s.define( 'User', {
deletedAt : {
type : Sequelize.DATE,