Sha*_*ika 4 mongoose mongodb node.js
我正在学习 Udemy for Node js 课程。猫鼬预中间件与删除一起使用,如下所示。
ReviewSchema.pre('remove', function() {
// code goes here
});
Run Code Online (Sandbox Code Playgroud)
但我的实现不同,我想使用 findByIdAndDelete。这是我的代码。
ReviewSchema.pre('findByIdAndDelete', function() {
// code goes here
});
Run Code Online (Sandbox Code Playgroud)
但这个不会触发。我尝试在其中console.log,但它没有触发。我在这里做错了什么?
| 归档时间: |
|
| 查看次数: |
2881 次 |
| 最近记录: |