mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
Added no-argument overload for Model.previous (#29385)
* Added no-argument overload for Model.previous `Model.previous()` in Sequelize called with no arguments returns an object containing the previous keys and values for properties that have changed. This pull request adds this overload to the Model.d.ts type definition file along with a comment documenting it. * Added test for Model.previous w no arg
This commit is contained in:
5
types/sequelize/index.d.ts
vendored
5
types/sequelize/index.d.ts
vendored
@@ -2890,9 +2890,12 @@ declare namespace sequelize {
|
||||
changed(): boolean | string[];
|
||||
|
||||
/**
|
||||
* Returns the previous value for key from `_previousDataValues`.
|
||||
* If previous is called with a string, it will return the previous value for the key from `_previousDataValues`.
|
||||
*
|
||||
* If previous is called without an argument, it will return an object containing the previous keys and values that have changed.
|
||||
*/
|
||||
previous(key: keyof TAttributes): any;
|
||||
previous(): object;
|
||||
|
||||
/**
|
||||
* Validate this instance, and if the validation passes, persist it to the database.
|
||||
|
||||
@@ -833,6 +833,7 @@ user.changed( 'name' );
|
||||
user.changed();
|
||||
|
||||
user.previous( 'name' );
|
||||
user.previous();
|
||||
|
||||
user.save().then( ( p ) => p );
|
||||
user.save( { fields : ['a'] } ).then( ( p ) => p );
|
||||
|
||||
Reference in New Issue
Block a user