Back to Data Sources
🍃

MongoDB

Query collections and chart documents alongside your SQL data

Connection Settings

FieldDescriptionExample
Connection stringStandard MongoDB URI, including credentials and options (encrypted at rest)mongodb://user:pass@host:27017
DatabaseDatabase to queryanalytics
Pool sizeMaximum connections in the pool (default: 5)5
TimeoutConnect timeout in seconds (default: 30)30

Both mongodb:// and mongodb+srv:// URIs work, so Atlas clusters and options such as tls=true or authSource=admin go straight into the connection string.

Features

Schema Inference

Fields are inferred from a sample of documents in each collection

Schema Browser

Browse databases and collections like tables in the SQL editor

TLS via URI

Enable TLS and auth options directly in the connection string

Connection Pooling

Configurable pool size for efficient resource usage

Query Syntax

MongoDB data sources accept a find-style query instead of SQL. Filters are JSON, so keys and string values must be double-quoted.

// Every document in a collection
orders

// Filter with a JSON document
orders.find({"status": "paid"})

// The db. prefix is optional
db.orders.find({"total": {"$gte": 100}})

// First matching document
db.customers.findOne({"email": "ada@example.com"})
OperationSupported
find()Yes, with an optional JSON filter
findOne()Yes, with an optional JSON filter
aggregate(), writesNot supported

Result rows respect the server's row limit, and nested documents and arrays are returned as JSON values.

Recommended Permissions

For read-only analytics, create a dedicated user with the built-in read role:

use admin
db.createUser({
  user: "dbcraft_reader",
  pwd: "secure_password",
  roles: [{ role: "read", db: "analytics" }]
})