Hi, am trying to find a mongodb document with same id and saving it with same data (Cloning) here is my piece of code, this code is creating document with empty data Packages.findById(req.body.id).exec( function(err, doc) { var newdoc = new Packages(doc); newdoc ._id = mongoose.Types.ObjectId(); newdoc.isNew = true; newdoc .save() .then((results) => { console.log('results', JSON.stringify(results)); res.json({ success: true, data: results }); }); } )
No responses yet.