RubyMine 2024.3 Help

Editing data in MongoDB

Modify data in the data editor

  1. Open the MongoDB collection in the data editor.

  2. Double-click the cell and modify a value.

    Click the Preview Pending Changes icon (the Preview pending changes icon) to see the DML.

    Preview pending changes icon

Add a document to a collection

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.

  1. In the Database tool window ( View | Tool Windows | Database) , double-click a MongoDB collection to open it in the data editor.

  2. 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 (The Add Row icon) in the toolbar.

  3. 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>.

  4. 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.

  5. Click the Submit button (The Submit button) in the toolbar.

Add a document to a MongoDB collection

Delete a document from a collection

For MongoDB, deleting a document from a collection is similar to deleting a row from a relational table.

  1. In the Database tool window ( View | Tool Windows | Database) , double-click a MongoDB collection to open it in the data editor.

  2. Select the document that you want to delete, right-click it and select Delete Row. Alternatively, click the Delete Row button (The Delete Row icon) in the toolbar.

  3. Click the Submit button (The Submit button) in the toolbar.

Delete a document from a MongoDB collection

View and edit data in a separate editor

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.

Add and delete columns

  • Right-click a header row of a column and select Add Column or Delete Column.

Last modified: 11 October 2024