Sailsjs beforeCreate not starting

I have an application with simple sails 0.9.8 with a very simple 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, so no encrypted password is created. I am sure that something is missing here, but I can’t understand that. Any idea?

+6
source share
1 answer

You must place beforeCreate outside the attributes. See https://github.com/balderdashy/sails-docs/blob/master/models.md#lifecycle-callbacks

+13
source

All Articles