strongloop / loopback

LoopBack makes it easy to build modern applications that require complex integrations.
http://loopback.io
Other
13.22k stars 1.2k forks source link

model hooks beforeUpdate not work #1721

Closed TNT-Likely closed 9 years ago

TNT-Likely commented 9 years ago

model hooks beforeUpdate not work

hope somebody can help me ,thanks.

Neil-UWA commented 9 years ago

use operation hooks instead. model hooks are deprecated.

TNT-Likely commented 9 years ago

@Neil-UWA it work,but how i can set some attribute?

this.xx='' not work

Neil-UWA commented 9 years ago
Model.beforeUpdate = function(next, modelInstance){
  modelInstance.xxx = '';
 next();
}

You can still use model hooks, but they are not recommended since they are deprecated. I suggest you to migrate from model hooks to operation hooks.

superkhau commented 9 years ago

use operation hooks instead. model hooks are deprecated.

This is correct. See https://docs.strongloop.com/display/public/LB/Operation+hooks