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:
devuxer
2018-10-03 11:49:11 -07:00
committed by Wesley Wigham
parent 35b5ebacbf
commit 430376c0b3
2 changed files with 5 additions and 1 deletions

View File

@@ -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.

View File

@@ -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 );