MongoDB 8 · Query and update operators

Remove a field

Delete a field from a document.

db.users.updateOne({ name: "Ada" }, { $unset: { legacyId: "" } })

Official MongoDB 8 documentation

More query and update operators commands

All query and update operators commands · MongoDB 8 cheatsheet

Was this page helpful?