All Products
Search
Document Center

Query a document

Last Updated: Jun 08, 2019

This section introduces how to query a document.

Prerequisites

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

Procedure

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

  2. After you log on to the instance, select Query Window in the top navigation bar to open the query window.

    mongodb-query-doc

  3. Select the database that contains the target document from the drop-down list, enter the query command in the command editing text box, and click Run (F8) to run the command.

    Note

    The query result is displayed on the execution result tab page at the bottom of the query window. If you run multiple query commands, all query results are displayed on the execution result tab page in the command execution order.

  • Document views

    The structure of documents is complex and similar to the JSON format. Therefore, DMS provides three document views. You can switch the document view by clicking the left-side tab.

    • JSON viewDocuments are displayed in JSON view by default, as shown in the following figure: Click an array in the document or click - or + to hide or show the elements under the array.

      json-view

    • List viewIn List view, Arrays, objects, and elements of documents are listed in a table using a hierarchical tree structure, as shown in the following figure: You can click the list arrow before an array, object, or item that contains elements to show or hide the elements under the array, object, or item. The List view displays detailed information about each element, such as the data type of an element. This view also supports editing documents.

      list-view

    • Text viewDocuments in Text view are displayed in the JSON text format with indents for you to quickly copy the content, as shown in the following figure:

      text-view