I have a blank sails 0.9.8 app with a very basic model:
module.exports = {
attributes: {
nickname: 'string',
encryptedPassword: 'string',
beforeCreate: function(values, next){
values.encryptedPassword = "123";
next();
}
}
};
When I create a new User from the console, the beforeCreate method is not called, thus no encryptedPassword created.
I'm sure I'm missing a little something here but cannot find out what. Any idea ?
You have to place beforeCreate outside of the attributes. See https://github.com/balderdashy/sails-docs/blob/master/models.md#lifecycle-callbacks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With