📜  mongodb findoneandupdate 返回更新 - Javascript 代码示例

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

代码示例1
//pass the {new: true} as the third option, if using mongodb driver use {returnOriginal: true}                                                      V--- THIS WAS ADDED
Cat.findOneAndUpdate({age: 17}, {$set:{name:"Naomi"}}, {new: true}, (err, doc) => {
    if (err) {
        console.log("Something wrong when updating data!");
    }

    console.log(doc);
});