I'm using monodb and mongoose. I have a pre findOneAndRemove
hook for Category
model
CategorySchema.pre('findOneAndRemove', function(next) {
Drink.remove({ category: this.getQuery()._id })
.exec((err) => next(err));
});
This hook will cascade and remove referencing documents from a collection called Drink
. I'm trying to setup a pre remove
hook for Drink
so I can cascade and remove documents from another collections. However this hook doesn't seem to get executed
DrinkSchema.pre('remove', function(next) {
console.log('removing');
});
Is it because hooks are not executed from inside another hook? I can't seem to find anything regarding this in the documentation
via Stanley Nguyen
No comments:
Post a Comment