【发布时间】:2019-05-29 21:15:11
【问题描述】:
这是我用来查找需要复制到其他集合的文档的代码:
public updateConfigWithType(req: Request, res: Response) {
configs.findOne({'companyInfo.uniquecompanyid': req.params.id}, function(err, config){
if (err) {
return res.send(err);
}
let swap = new (oldConfigs.model('oldConfigs'))(config)
swap.save()
config.parserConfig = req.body;
config.save(err => {
if (err) return res.send(err);
res.json({ data: config });
});
});
}
The error message is the following:
(node:65757) UnhandledPromiseRejectionWarning: DocumentNotFoundError: No document found for query "{ _id: {} }"
(node:65757) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
10:34:34 AM web.1 | (node:65757) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
不知道我将如何解决这个问题。我也得到两个不同的错误?我在这里缺少什么,请解释一下。
【问题讨论】:
标签: typescript express mongoose