mongodb findbyidandupdate upsert code example
Example: returned value by findOneAndUpdate
const filter = { age: 17 };
const doc = { $set: { name: "Naomi" } };
const options = { new: true };
Cat.findOneAndUpdate(filter, doc, options, (err, doc) => {
if (err) console.log("Something wrong when updating data!");
console.log(doc);
});