MongoDB

  • Last update:October 26, 2021
  • I. Overview

    MongoDB is a mainstream NoSQL database. After the MongoDB database plugin is installed (please contact our technical support support@fanruan.com for the plugin), data in the MongoDB database can be fetched through a visual interface.

    Note: Currently, MongoDB data connection can only be defined in the designer, not in the decision-making platform.

    You will learn
    • Steps

      • Add a data connection

      • Query simple type data

      • Query array type data

      • Query object type data

      • Query aggregate data

      • Use date and time in the query

    II. Steps

    1. Add a data connection

    1) After the plugin is installed, restart the designer (or the server remotely) and add a MongoDB data connection through the Define Data Connection pane.

    2) Enter information such as host ID, port number, username and password, and then test whether the connection is successful.


    2. Query simple type data

    1) Add a MongoDB collection dataset.

     

    Documents queried are listed below:


    2) In the Database Query pane, select a data connection, type the database name, choose a collection and then screen and sort the documents using the following two sets of statements:

    {$or:[{name:"H5Directory"},{type:'others'}]}

    {time:-1}

    Preview the effect:


    Note: Statements for screening can be placed in the column of either “Query Condition” or “Filter Condition”, both of which, equivalent to the SQL WHERE statement, show the same implementation effect.

    3) You can also add a parameter to the query, for example, modify the statement to:

    {$or:[{name:"H5Directory"},{type:'${type}'}]}

    Then refresh the parameters below and define the value of type as “others”. Click Preview and data fetched is the same as in the previous method.

     


    3. Query array type data

    Documents queried are listed below, including two array columns:

    1) Define the data connection, database and connection, but do not define any query condition.

    2) Click Preview to show all data queried, with the two array columns unfolded.

     

    4. Query object type data

    Documents queried are listed below, including an object column:

    1608617686336917.png

    1) Define the data connection, database and collection, but do not define any query condition.

    2) Data queried is listed below:


    3) Specify the columns to be displayed: value, name.O and name.P, so that elements in the object are listed in separate columns.


    4) Preview:



    5. Query aggregate data

    Documents queried are listed below:

    1) Create a new aggregate data.

    Note: Only V9.0 and later support Aggregate Data.

     

    2) Define the data connection, database and collection, add an aggregate condition, choose $group as the operator and Object as the value type.

    3) Define the value as:

    {_id:"$by_user",num_tutorial:{$sum:1}}


    4) Preview:



    6. Use date and time in the query

    1) Method 1: 

    use data in date format as the parameter and define the value of the parameter below, for example, set the query condition to:

    {time:{$lt:ISODate("${date}")}}

    The value of the parameter is defined as a date.


    Query results are listed below:

    2) Method 2: 

    directly enter time in ISO standard format as the query condition:

    {time:{$gt:ISODate("2017-02-17T00:00:00.000Z")}}

    Query results are listed below:

    3) Method 3: 

    query in the form of an aggregate dataset and use a date object as the query condition:

    {'time':{$gt:new Date("2017-02-17 00:00:00")}}

    Corresponding data can be queried. However, as time used in this method is not in ISO standard format, errors will occur in the query and this method is not recommended.


    Note: For details about the use of date formats in MongoDB, see the official documentation: Date()

    Attachment List


    Theme: Data Preparation
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy