javascript - Get current values inside Sails' Waterline beforeUpdate hook -


in sails' waternline need able compare previous value new 1 , assign new attribute under condition. example:

beforeupdate: function(newvalues, callback) {    if(/* currentvalues */.age > newvalues.age) {      newvalues.permission = false;    } } 

how access currentvalues ?

i'm not sure best solution can current record doing simple findone request:

beforeupdate: function(newvalues, callback) {   model     .findone(newvalues.id)     .exec(function (err, currentvalues) {       // handle errors       // ...        if(currentvalues.age > newvalues.age) {         newvalues.permission = false;       }        return callback();     }); } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -