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

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - On Gitbash - Bower : ENOGIT git is not installed or not in the PATH -