mongoose删除model时,pre和post middleware为什么不会触发
blogSchema.pre('remove’, function(next){ console.log(‘before remove blog’); console.log(this.id); console.log(this.comments); next(); }); blogSchema.post('remove’, function (doc) { console.log(‘remove blog’); console.log('%s has been removed’, doc._id); });
Blog.findByIdAndRemove(id, function(error, blog){ DBUtil.handleQueryResult(error, blog, options); });