# MongoDB

## 1. How to connect to MongoDB?

Acho allows you to connect to MongoDB database. You can follow the steps below to set up the connection. Go to the **Resources** page and click the **Add Resource** button

2\. In the "Select a data source" step, select **MongoDB** under the **Database** tab

3\. In the "Configure the data source" step, enter your database login credentials:

* **`Database`**: your database name.
* **`User`**: the username used for connecting to your database.
* **`Password`**: the password used for authenticating the connection.
* **`TLS Connection`**: whether to use TLS connection.
* **`Authentication Source`**: specifies the database that the supplied credentials should be validated against. The default value is "admin".
* **`MongoDb Instance Type`**: Acho supports three instance types:
  * **Standalone MongoDB instance**
    * Host: URL of the database
    * Port: Port to use for connecting to the database
  * **Replica Set**
    * Server addresses: the members of a replica set
    * Replica Set: A replica set name
  * **MongoDB Atlas Cluster:** it can be a little tricky if you are not familiar with MongoDB's connection string. Here is an example breaking down components in a MongoDB SRV connection string:
    * Database: <mark style="color:green;">db-name</mark>
    * User: <mark style="color:green;">username</mark>
    * Password: <mark style="color:green;">password</mark>
    * Cluster URL: URL of a cluster to connect to (<mark style="color:red;">rs.joedrumgoole.com</mark> in this example)

![Example of the SRV connection string in MongoDB official document](https://3574406564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_fx7PCUqvFEdrucJC%2Fuploads%2FxSIMGvHH1Zd6iOImpWnP%2Fsrv-process.png?alt=media\&token=6cb076f7-2f36-40f8-b9b7-b13ede6773e8)

{% hint style="info" %}
Note: remember to add Acho's IP address, **`35.239.14.24`**, to your [whitelist](#3.-how-to-add-achos-ip-into-your-whitelist) before starting the connection.
{% endhint %}

4\. In the "Select the tables", choose tables that you want to import.

5\. Click **Finish Setup**. You will see a <img src="https://3574406564-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB_fx7PCUqvFEdrucJC%2F-MgBh5PshcmRFk38itib%2F-MgBo4LSmdK4OS-NqLZy%2Fsyncing.png?alt=media&#x26;token=452494f9-e4be-48fa-9644-bee7d969c46c" alt="" data-size="line"> icon next to your MongoDB resource. It may take a few minutes to several hours depending on the data size and the number of your tables. Once your APP's data is ready, you will receive a notification email.&#x20;

## 2. How to set up Data Sync?

Acho supports creating schedulers to retrieve the latest data from your database at a certain time interval. To see more details, you can visit [here](https://docs.acho.io/data-sync/untitled).

## 3. How to add Acho's IP into your whitelist?

You should whitelist our service IP address `35.239.14.244` . This way we can make a connection to your database and import the tables to **Acho Studio**. Here is how you can whitelist Acho's service IP address for your database instance. (Take MongoDB Atlas as an example).

1\. Go to your MongoDB Atlas and navigate to **Network Access**

2\. Click on **ADD IP ADDRESS**, and enter **`35.239.14.244`** in **Access List Entry** as shown below

{% hint style="info" %}
If you need to input an IP range, just ente&#x72;**`35.239.14.244`**
{% endhint %}

3\. Click **Confirm**

![](https://3574406564-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB_fx7PCUqvFEdrucJC%2F-MjpWH5X6Wuz2FkyyTck%2F-MjpoX9D2OLQB0ceDk9s%2Fimage.png?alt=media\&token=d43d8387-98ac-400c-a270-84ebd1f4d7dd)
