【发布时间】:2017-08-30 15:07:32
【问题描述】:
在删除公司时,我尝试删除 mongoDb 中的引用文档。但是在我执行之后,它只会删除公司而不执行中间件主体
const removedCompany = await CompanyModel.findOne({ _id: id }).remove();
内部架构文件
CompanySchema.pre('remove', (next) => {
// 'this' is the company being removed. Provide callbacks here if you want
// to be notified of the calls' result.
UserCompany.remove({ companyId: this._id }).exec();
next();
});
【问题讨论】:
标签: node.js mongodb mongoose serverless-framework