Editing data in MongoDB
Open the MongoDB collection in the data editor.
Double-click the cell and modify a value.
Click the Preview Pending Changes icon (
) to see the DML.
For MongoDB, adding a document to a collection is similar to adding a row to a relational table. The difference is that it is not mandatory for all the documents of a collection to have the same fields.
In the Database Explorer (View | Tool Windows | Database Explorer) , double-click a MongoDB collection to open it in the data editor.
To add the draft of a document, right-click any area in the data editor and select Add Row. Alternatively, click the Add Row button (
) in the toolbar.
Change the values of fields from
<unset>
to the required ones.If a specific field is not required in the new document, or must be generated upon the new document creation (for example, the values of
_id
column), leave it as<unset>
.If you need to add the fields that are not currently present as columns in the new document, right-click any area in the data editor and select Add Column. Set the values of your new fields for the new document.
Click the Submit button (
) in the toolbar.
![Add a document to a MongoDB collection Add a document to a MongoDB collection](https://resources.jetbrains.com/help/img/idea/2024.3/db_mongodb_add_document_to_collection.png)
For MongoDB, deleting a document from a collection is similar to deleting a row from a relational table.
In the Database Explorer (View | Tool Windows | Database Explorer) , double-click a MongoDB collection to open it in the data editor.
Select the document that you want to delete, right-click it and select Delete Row. Alternatively, click the Delete Row button (
) in the toolbar.
Click the Submit button (
) in the toolbar.
![Delete a document from a MongoDB collection Delete a document from a MongoDB collection](https://resources.jetbrains.com/help/img/idea/2024.3/db_mongodb_delete_document_from_collection.png)
You can view and edit data and also raw JSON in a separate editor.
Right-click a cell in the collection opened in the data editor and select Open in Value Editor.
In the separate editor, you can wrap long values and change their types. To wrap a value, click Toggle Soft-Wrap. To change the type, click the type list and select the necessary value. Alternatively, to change a type, you can right-click a cell and select Change Type.
Right-click a header row of a column and select Add Column or Delete Column.
Thanks for your feedback!