1//pass the {new: true} as the third option, if using mongodb driver use {returnOriginal: true} V--- THIS WAS ADDED
2Cat.findOneAndUpdate({age: 17}, {$set:{name:"Naomi"}}, {new: true}, (err, doc) => {
3 if (err) {
4 console.log("Something wrong when updating data!");
5 }
6
7 console.log(doc);
8});
9
1
2var oldPLoad = msg.payload;
3delete oldPLoad._id;
4
5msg.payload = [
6 {
7 "_id":msg._id,
8 },
9 {
10 $set:oldPLoad
11 },
12 {
13 upsert: true,
14 returnOriginal:false
15 }
16];