场景:
查询:
pre
中间件在插入/保存之前检查每条记录吗? 最佳答案
您可以使用
Schema.post('insertMany', function (docs, next) {
docs.map((doc) =>
console.log(doc)
);
});
或者Schema.pre('insertMany', function (docs, next) {
docs.map((doc) =>
console.log(doc)
);
});
关于node.js - 如何在批量插入中使用 Mongoose 预中间件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40809030/