📌  相关文章
📜  mongoose 保存或更新 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:21.595000             🧑  作者: Mango

代码示例4
// SAVE NEW OR UPDATE EXISTING COLLECTION
AnnoucementTagsModel.findOneAndUpdate({_id: announcementId}, newAnnoucementTags, {upsert: true}, function (err, doc) {
    if (error) throw new Error(error);
    console.log("succesfully saved");
});