You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
model.find({id:id}).remove(function(err){ db.close(); _this.sendAllRequestsToClient(); });
Everything is ok, removing works excelent. But hook beforeRemove is not triggered. Could anyone tell me if am I doing something wrong? thanks
beforeRemove: function(next){ var _this = this; console.log('beforeRemove ok OK OK OK OK OK OK OK '); this.getTaxi(function(err,taxi){ console.log('taxi sa nasiel akopan'); taxi.reserved=0; taxi.save(); next(); }); }
The chained remove operates on a list of items rather than individual ones.
Because of this, it does a batch deletion rather than instantiating every single item - and without instantiating, it can't run hooks.
I want to fix this in 2.1.5.
The idea is to have something like:
.find().remove(function(err){...})// remove hooks fired.find().remove(fireHooks: false,function(err){...})// remove hooks not fired
so that people can either get the default expected behaviour or the non hook running fast behaviour.
Activity
dxg commentedon Mar 13, 2014
The chained remove operates on a list of items rather than individual ones.
Because of this, it does a batch deletion rather than instantiating every single item - and without instantiating, it can't run hooks.
I want to fix this in 2.1.5.
The idea is to have something like:
so that people can either get the default expected behaviour or the non hook running fast behaviour.
FilipLukac commentedon Mar 13, 2014
I want to delete by PK, but I dont know how and I didn't found it. I tried to model.get(id).remove(); and this didn't go well, server crashed
dxg commentedon Mar 14, 2014
.getisn't chainable at the moment; onlyfindand a few others are.To delete just one item, you can:
FilipLukac commentedon Mar 15, 2014
again.. Thanks !
bvallelunga commentedon Mar 24, 2014
@dxg has any progress been made on this issue?
dxg commentedon Mar 24, 2014
Not yet. First I need to sort out #375 then I'll get onto this one.
jacobp100 commentedon Nov 4, 2014
Maybe we could check if the model has remove callbacks as well as the optional 'don't fire remove hooks'.