mardi 22 avril 2014

Is there a better way to avoid duplicate lifecycle callbacks?


Vote count:

0




Waterline allows for some lifecycle callbacks on models as listed below...



  • beforeValidation / fn(values, cb)

  • beforeCreate / fn(values, cb)

  • afterCreate / fn(newlyInsertedRecord, cb)

  • beforeValidation / fn(valuesToUpdate, cb)

  • beforeUpdate / fn(valuesToUpdate, cb)

  • afterUpdate / fn(updatedRecord, cb)

  • beforeDestroy / fn(criteria, cb)

  • afterDestroy / fn(cb)


However, what if I want to take action before create and update?


Rails had a beforeSave which was great for this. Is there something similar in sails.js?


I could have both callbacks call a function, but I want to be sure there isn't a better way.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire