Skip to content

Commit

Permalink
handle manually set update ts
Browse files Browse the repository at this point in the history
so the create and update are having the same logic of 3 conditions: 
 a. key given;
 b. new model / value changed; 
 c. ts not manually set;
  • Loading branch information
eerenyuan committed Sep 15, 2018
1 parent 30ffc63 commit 58ddd95
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/base/model.js
Expand Up @@ -643,7 +643,7 @@ ModelBase.prototype.timestamp = function(options) {
const updatedAtKey = timestampKeys[1];
const isNewModel = method === 'insert';

if (updatedAtKey && (isNewModel || this.hasChanged())) {
if (updatedAtKey && (isNewModel || this.hasChanged()) && !this.hasChanged(updatedAtKey) ) {
attributes[updatedAtKey] = now;
}

Expand Down

0 comments on commit 58ddd95

Please sign in to comment.