Update Documents
updateOne and updateMany change documents with update operators such as $set. Without an operator you would replace the document, so always use one.
Example
db.students.updateOne({ name: "Ada" }, { $set: { city: "Abuja" } })
db.students.updateMany({}, { $set: { active: true } })Exercise
Change a field.
{ $: { city: "Abuja" } }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.