All Products
Document Center

Modify a document

Last Updated: Jun 08, 2019

This section describes how to modify a document.


You must have access permissions to DMS and be logged on to the DMS console.


  1. Select an ApsaraDB for MongoDB instance and then click Log on to Database.

  2. After you log on to the instance, expand the left-side object list, select the collection that contains the target document, right-click the collection, and then select Check Data to open the query window.


  3. By default, a query command is executed in this window to query the documents in the collection. You can add query conditions to find the document that you need to modify. Select the List view on the execution result tab page, as shown in the following figure:


  4. You can choose to modify the elements in the document or directly modify the document.

    • Modify elementsUse this method if you only need to modify a small number of elements in a document, without the need to change the structure of the document.


    1. Locate the target element and then click the element. If the element is user-configurable, the edit mode is enabled.


      The edit mode varies depending on the data type of the element. For a time type element, a calendar is displayed. For a bool type element, a drop-down list that contains bool values is displayed. For a string type element, a text box is displayed.

    2. After editing the element, click another element to complete editing the current element. Confirm the element modification command in the review dialog box and then click OK to submit the changes.

    3. To delete an element, first select the element in the element list. To avoid entering the edit mode, you can select the element by clicking the name or type of the element.

      1. Right-click the element and then select Delete Current Element.

      2. Confirm the element deletion command in the review dialog box and then click OK to delete the element.mongodb-edit-doc-3

    • Modify documentsThe procedure of modifying a document is similar to creating a document. This method is used to replace the content in a document. Use this method if you need to make a large amount of changes to the document, for example, operations such as addition or deletion. This will change the structure of the document.


    1. Select the target document in the List view, select any element of the document, and click Edit Document to open the edit window.

    2. Modify the content of the document in the edit window. The content must be compliant with the MongoShell standards.


      • You can choose to enclose element names in double quotation marks (“”).
      • When an element name contains spaces, it must be enclosed in double quotation marks (“”).
      • To delete an element, delete it in the edit window.
      • To add an element, add it in the edit window.Note:

    When you modify an element, use the format specified for the corresponding data type. Incorrect format may change the type of the element. For example, the format of Value: NumberInt(123) means that the data type of the Value is Integer. If you change the format to Value: 123, it means that the data type of the Value is Double. If you submit the change, the data type of the Value is then changed from Integer to Double.

    1. After you modify the document, click Check Format to check the format of the document. If the Format check successful message is displayed, the document has passed the format check. Otherwise, modify the content according to the error messages.

    2. After the format check is complete, click OK in the edit window. Confirm the document modification command in the review dialog box, and then click OK to submit the changes.