You can call beforeUpdate
from beforeCreate
, or vice versa:
beforeCreate: function(values, cb) {
// Forward to the model's beforeUpdate method
return User.beforeUpdate(values, cb);
},
beforeUpdate: function(valuesToUpdate, cb) {
...
}
Just keep in mind that the values sent via an update
call will likely be different than the ones sent to create
; for instance, don't rely on an instance's id
value being available!