Modify Documents¶
You can edit existing documents in your collection.
When you edit a document in List or Table view, Compass performs a findOneAndUpdate operation and updates only those fields that you have changed.
When you edit a document in JSON view, Compass performs a findOneAndReplace operation and replaces the document.
Limitations¶
- Modifying documents is not permitted in MongoDB Compass Readonly Edition.
- You cannot use the MongoDB Compass GUI to modify documents in a sharded collection. As an alternative, you can use the Embedded MongoDB Shell in Compass to modify a sharded collection. To learn more about updates on sharded collections, see Sharded Collection Behavior.
Procedure¶
Select the appropriate tab based on whether you are viewing your documents in List, JSON, or Table view:

To modify a document, hover over the document and click the pencil icon:

After you click the pencil icon, the document enters edit mode:

You can now make changes to the fields, values, or data types of values.
Delete Fields¶
To delete a field from a document, click the x
icon to the
left of the field:

Once selected, the field is marked for removal and appears highlighted in red:

Add New Fields¶
To add a new field in the document after an existing field, hover over the row number in the dialog and click on the plus sign. The row number is not part of the document but is part of the dialog display.
You can also add a new field at the end of the document by pressing the tab key when your text cursor is in the value of the last document field.
Modify an Existing Field¶
To modify documents, click on existing field names or
values and make changes. In this example, the flight status was
changed from L
to M
. Changed fields appear highlighted in
yellow:

When you edit a document in List or Table view, Compass performs a findOneAndUpdate operation and updates only those fields that you have changed.
If Compass detects that you have changed fields that were modified outside of Compass, it notifies you, preventing you from accidentally overwriting the changes made outside of Compass. You can choose to proceed and replace the document by clicking Update, or cancel your changes.
Save Changes¶
When you are finished editing the document, click the Update
button to commit your changes.
Revert a Change¶
To revert changes to a document, hover over the edited field and click the revert icon which appears to the left of the field's line number.

Cancel Changes¶
To exit the edit mode and cancel all pending changes to the document, click the Cancel button.