Answers for "mongodb findoneandupdate return updated"

0

mongodb findoneandupdate return updated

//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);
});
Posted by: Guest on May-24-2021
0

findOneAndUpdate in Mongo database

var oldPLoad = msg.payload;
delete oldPLoad._id;

msg.payload = [
    {
        "_id":msg._id,
    },
    {
        $set:oldPLoad
    },
    {
        upsert: true,
        returnOriginal:false
    }
];
Posted by: Guest on August-13-2021

Code answers related to "mongodb findoneandupdate return updated"

Code answers related to "Javascript"

Browse Popular Code Answers by Language