Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top