Skip to content

Commit

Permalink
fix(types): add version property to init options (#10681)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSchick authored and sushantdhiman committed Apr 2, 2019
1 parent c9e48e4 commit 0f505ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions types/lib/model.d.ts
Expand Up @@ -1029,7 +1029,7 @@ export interface ModelValidateOptions {
}

/**
* Interface for indexes property in DefineOptions
* Interface for indexes property in InitOptions
*/
export interface ModelIndexesOptions {
/**
Expand Down Expand Up @@ -1072,7 +1072,7 @@ export interface ModelIndexesOptions {
}

/**
* Interface for name property in DefineOptions
* Interface for name property in InitOptions
*/
export interface ModelNameOptions {
/**
Expand All @@ -1087,14 +1087,14 @@ export interface ModelNameOptions {
}

/**
* Interface for getterMethods in DefineOptions
* Interface for getterMethods in InitOptions
*/
export interface ModelGetterOptions {
[name: string]: (this: Model) => unknown;
}

/**
* Interface for setterMethods in DefineOptions
* Interface for setterMethods in InitOptions
*/
export interface ModelSetterOptions {
[name: string]: (this: Model, val: any) => void;
Expand Down Expand Up @@ -1389,6 +1389,16 @@ export interface ModelOptions<M extends Model = Model> {
* Allows defining additional getters that will be available on model instances.
*/
getterMethods?: ModelGetterOptions;

/**
* 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.
* - If string: Uses the named attribute.
* - If boolean: Uses `version`.
* @default false
*/
version?: boolean | string;
}

/**
Expand Down
1 change: 1 addition & 0 deletions types/test/models/User.ts
Expand Up @@ -37,6 +37,7 @@ User.init(
username: DataTypes.STRING,
},
{
version: true,
getterMethods: {
a() {
return 1;
Expand Down

0 comments on commit 0f505ef

Please sign in to comment.