> ## Documentation Index
> Fetch the complete documentation index at: https://docs.textql.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MongoDB Connector

> Connecting TextQL to MongoDB

To connect TextQL with your MongoDB cluster, gather the following connection details:

* Host (the cluster DNS name for Atlas, or a hostname/IP)
* Port (default 27017; ignored when using an SRV connection)
* Database (optional — leave blank to query every database in the cluster)
* Auth Source (the database your user authenticates against; `admin` for most Atlas users)
* Authentication credentials (username and password)
* SRV and TLS options

### How TextQL queries MongoDB

MongoDB is a document database, so TextQL queries it with native **aggregation pipelines** (`db.<collection>.aggregate([...])`) rather than SQL. Collections appear as tables; nested document fields are exposed as dot-paths (`address.city`) and arrays as array fields you can `$unwind`. Query results are returned as a normal table.

<Warning>
  Use a **read-only** MongoDB user for this connector. TextQL only issues read queries, but aggregation pipelines can technically include write stages (`$out`, `$merge`) — a read-only user guarantees the connector can never modify your data regardless of the query. In MongoDB Atlas, assign the built-in **`readAnyDatabase`** role (or **`read`** on a specific database).
</Warning>

### Creating the Connector in TextQL

Navigate to the [TextQL Connectors Page](/core/datasources/the-connectors-page) and click **Create New Connector**. Select MongoDB to open the configuration form.

The form requires:

* **Connector Name:** A descriptive name for this connection.
* **Host:** Your MongoDB host. For Atlas, the cluster DNS name (e.g. `cluster0.abc123.mongodb.net`) — paste only the host, not the full `mongodb+srv://` string.
* **Port:** The MongoDB port (default 27017; ignored when SRV is enabled).
* **Database:** The database to query. **Optional** — leave blank to expose every (non-system) database, with collections referenced as `database.collection`. When blank, the user needs the `listDatabases` privilege.
* **Auth Source:** The database the user authenticates against (default `admin`).
* **Username / Password:** Your MongoDB credentials.
* **Use SRV connection:** Enable for MongoDB Atlas (`mongodb+srv`), which resolves the cluster's hosts via DNS and implies TLS.
* **Use TLS:** Enable TLS for the connection (required by Atlas).

### MongoDB Atlas

For an Atlas cluster, your connection string looks like:

`mongodb+srv://<user>:<password>@cluster0.abc123.mongodb.net/`

Map it to the form as:

* **Host:** `cluster0.abc123.mongodb.net`
* **Use SRV connection:** on
* **Use TLS:** on
* **Auth Source:** `admin`
* **Username / Password:** the database user's credentials

Make sure your TextQL egress IP is added to the Atlas **Network Access** allowlist.

### Testing the Connection

After entering your credentials, click **Create**. TextQL validates the connection and creates the connector. If it fails, verify the host, credentials, and (for Atlas) the Network Access allowlist.

<Note>
  Having trouble connecting? See the [Network Configuration Guide](/core/datasources/databases/network-configuration) for firewall and IP whitelisting setup.
</Note>
