Configuring Database connectors - NoSQL (MongoDB)

You have seen how you can add Relational Databases like MySQL, Microsoft SQL, PostgreSQL to your apps. Studio also offers the connector to connect to different NoSQL DB such as MongoDB.
Let us consider MongoDB which is a document-based database here. You can use the connector to carry out various operations including querying and inserting and updating details.

To use the MongoDB datasets you simply need to add the MongoDB connector, configure the connector using the database details, provide the necessary values, and test it before you validate. Once your configuration is complete you can add a query as per your requirement.

Let us first have a quick look at the video here to understand how to configure the MongoDB connector.

Adding a MongoDB Connector

To add a MongoDB connectors, under Studio > Connectors, click (+) Connector. Select the MongoDB category and click Add.

|405.15184893784436x355

Configure Database Category

You first need to provide the details of your Connector, thus enter a Category name and Category description. Add an appropriate icon and click Continue.

The most important part of the process is to provide connection configuration details.

You would now need to add the Connection string fields. These are non-editable fields, you cannot add or remove these fields.

In this case, note that to connect to the MongoDB database/dataset you would need a few parameters or fields. Here, we will be taking a sample public MySQL database sample_airbnb.

The connection parameters that are required are Host, database, and Account name. You also can enter the respective username, password, and port number and click Submit.

Once these configurations are done, you need to Test the request and connection. If the authentication is successful you would get the response accordingly. You can now click Continue to Finish and Save your configuration.

Add query to the Database connector

The DB connector is now added to the Custom Database connectors section. You would have the Add query to the database.

First, give a name with which the query would be available for use. Now provide the b. The actions supported by MongoDB are listed out. Select the action represented by the name. You will find parameters depending upon the action. For example, if your action is Find the parameters would be Filter, projection, sort, limit, and skip. If you choose InsertOne as action, the parameter would change to Insert as Key: Value string. Once you have assigned the necessary values, you can Run the query. The response can be seen as per the parameters given.

You can also add dynamic values using the Variables. You can add the variable using Variables > +Add.

Add the FieldName and select the Field type. Ensure that you select the field type that matches the column type of the table so that the query works correctly. Add a Test Value to check the results before saving. You can also add a Default value or make it Mandatory. Add the Help text that would be shown with the field. You can also add any preset formula. Once you have entered the details, click Add Variable. The variable would be listed under Variables. You can make use of the variable in the query where you created the variable.

To use a variable inside a query, you simply need to put it into double Curly brackets. The Test value that you entered would be considered used when you are running this query here for testing. Adding variables is similar to other DB Connectors that we have used.

You can now view the queries that you saved for using in your apps later under your specific connector under Custom Database connectors.

Now that you want to make use of these Database connectors in your Apps, Under your app, click Connectors > + Add. From the list of connectors select Custom Database Connectors > Your connector, and click Continue.

Now select from your connector query that would be used to fetch data and click Continue .

Now your account needs to be authenticated. So select your Connected Account and click Continue. You can now configure the connector’s fields. Add the input values and click Finish.

Based on the query selected, you would have the connector fields that would be used in the BINDAPI formula.

Now whenever you run the app, you can see the results based on the input values.

Using the MongoDB Connector is similar to using the sheets with your apps. You can make use of the different Queries to fetch data as well bind data such that you can undertake the insert, update, delete actions as well.

You can refer to this link here to understand how to use the API services.