📜  是找到一个并更新返回更新状态? - Javascript代码示例

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

代码示例1
// Pass {new: true} if you want the updated result in the doc variable:
Cat.findOneAndUpdate({age: 17}, {$set:{name:"Naomi"}}, {new: true}, (err, doc) => {
    if (err) {
        console.log("Something wrong when updating data!");
    }

    console.log(doc);
});