Delete one or more fields from matched documents.
Section: Field update operators
Remove a field
javascript
javascript
db.users.updateMany({ legacy_flag: { $exists: true } }, { $unset: { legacy_flag: "" } })Explanation
`$unset` removes the field from documents instead of setting it to null.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Field update operators