Here is the code snippet I am currently using to locate the document that needs to be duplicated to another collection:
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 being displayed is:
(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.
I am uncertain on how to address these issues. Can someone please explain what I am overlooking here?