Question

Hi while I have implemented bcrypt beforeCreate function there are two ways people implemented that with a function signature

beforeCreate: function (user, next, cb) 

or with a function signature

beforeCreate: function (user, cb) 

and they call either cb() or next() after finishing the function, I am wondering which is the better way and why?

Was it helpful?

Solution

Most of the Sails/Waterline lifecycle callbacks should have two parameters: values which is an object containing values of the record's fields and cb which is a callback to be called once everything is done. So, the right signature would be:

beforeCreate: function (values, cb) { ... }

See Waterline readme for all lifecycle callback signatures.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top