diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 9ffda92873..4d41675ba3 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -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; } /** diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index 9000dd92b0..c2a171109f 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -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,