findOneAndUpdate
Update and return the document.
Example
db.users.findOneAndUpdate(
{ name: "Ada" },
{ $inc: { age: 1 } },
{ returnDocument: "after" }
)Exercise
Return new doc.
returnDocument: ""
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.