1
試圖複製文檔。首先我找到它。然後刪除_id。然後插入它。但是calculate._id仍然存在。所以我得到了重複錯誤。我究竟做錯了什麼?貓鼬(mongo),複製文檔
mongoose.model('calculations').findOne({calcId:req.params.calcId}, function(){
if(err) handleErr(err, res, 'Something went wrong when trying to find calculation by id');
delete calculation._id;
console.log(calculation); //The _.id is still there
mongoose.model('calculations').create(calculation, function(err, stat){
if(err) handleErr(err, res, 'Something went wrong when trying to copy a calculation');
res.send(200);
})
});