MongoDB 8 · Create, read, update, delete

Update or insert

Update a document, or insert it when none matches.

db.users.updateOne({ email: "[email protected]" }, { $set: { name: "New" } }, { upsert: true })

Official MongoDB 8 documentation

More create, read, update, delete commands

All create, read, update, delete commands · MongoDB 8 cheatsheet

Was this page helpful?