不要怂,就是干,撸起袖子干!

Commit 0f505eff by Simon Schick Committed by Sushant

fix(types): add version property to init options (#10681)

1 parent c9e48e48
Showing with 15 additions and 4 deletions
......@@ -1029,7 +1029,7 @@ export interface ModelValidateOptions {
}
/**
* Interface for indexes property in DefineOptions
* Interface for indexes property in InitOptions
*/
export interface ModelIndexesOptions {
/**
......@@ -1072,7 +1072,7 @@ export interface ModelIndexesOptions {
}
/**
* Interface for name property in DefineOptions
* Interface for name property in InitOptions
*/
export interface ModelNameOptions {
/**
......@@ -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;
......@@ -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;
}
/**
......
......@@ -37,6 +37,7 @@ User.init(
username: DataTypes.STRING,
},
{
version: true,
getterMethods: {
a() {
return 1;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!