MongoDB.
Connect Orchid to MongoDB Atlas, self-hosted MongoDB, or a DocumentDB-compatible deployment. Cells use MongoDB's native query syntax — find, aggregation pipelines, and a small set of helpers.
This connector is on the v1.1 roadmap. The setup steps below are the planned flow.
Requirements
- MongoDB 5.0+ recommended.
- A connection string from your provider (Atlas, self-hosted, etc.).
- A database user with at least
readon the databases you want to query.
Connect
- Open Integrations → + Add connection → MongoDB.
- Paste your connection string, or fill in the fields manually:
- Connection string — e.g.
mongodb+srv://user:pass@cluster.mongodb.net/mydb?retryWrites=true&w=majority - Database — the default database to query against
- Connection string — e.g.
- Click Test connection. Green check = ready.
Connection string format
MongoDB uses URI-style connection strings. Two common shapes:
# Standard format (self-hosted, single host or replica set)
mongodb://username:password@host1:27017,host2:27017,host3:27017/mydatabase?replicaSet=rs0&authSource=admin
# DNS-seedlist format (Atlas, simpler)
mongodb+srv://username:password@cluster0.mongodb.net/mydatabase?retryWrites=true&w=majority
Useful URI parameters:
authSource— which database holds the user's credentials. Almost alwaysadmin.replicaSet— for replica-set discovery.tls=true— required for Atlas.retryWrites=true— retries idempotent writes after a transient failure.w=majority— write concern; default in Atlas.
Optional settings
Atlas IP allow list
Atlas blocks connections from un-allow-listed IPs. Add your current IP in Network Access → Add IP address. For a long-lived setup, allow a range from your office or VPN. For ad-hoc work, click Add Current IP Address from the Atlas UI.
SSH tunnel
Self-hosted MongoDB on a private VPC works through an SSH tunnel like any other connector. Bastion host, user, private key.
Writing queries
MongoDB cells use MongoDB shell syntax. Orchid wraps it in a small evaluation surface that returns documents to the result table.
Simple find
db.users.find(
{ status: "active", created_at: { $gt: ISODate("2026-04-01") } },
{ name: 1, email: 1, last_login: 1 }
).limit(50)
Aggregation pipeline
db.orders.aggregate([
{ $match: { created_at: { $gt: ISODate("2026-04-01") } } },
{ $group: {
_id: { day: { $dateTrunc: { date: "$created_at", unit: "day" } } },
orders: { $sum: 1 },
revenue: { $sum: "$total" }
}},
{ $sort: { "_id.day": 1 } }
])
Lookup (join)
db.orders.aggregate([
{ $match: { status: "shipped" } },
{ $lookup: {
from: "users",
localField: "user_id",
foreignField: "_id",
as: "user"
}},
{ $unwind: "$user" },
{ $project: { _id: 1, total: 1, "user.email": 1 } }
])
Orchid renders Mongo aggregation results as a flat table. Nested fields are shown with dotted paths (e.g. user.email). Click any row to see the full JSON document in the cell's detail panel.
Common gotchas
- "MongoServerError: bad auth" — wrong username/password, or wrong
authSource. Almost always fixed by adding?authSource=adminto the URI. - "MongooseServerSelectionError: connection timed out" — Atlas IP not allow-listed, or self-hosted server not reachable. Check your IP allow list first.
- Slow first query — Atlas free-tier clusters pause after inactivity. First query after a pause takes ~5 seconds while the cluster resumes.
- "Field path references must be prefixed with a dollar sign" — you wrote
$group: { _id: "user_id" }(string literal) instead of$group: { _id: "$user_id" }(field reference). MongoDB takes the dollar prefix seriously. - Numbers come back as
NumberLong/NumberDecimal— Mongo's extended JSON types. Orchid converts these to regular numbers in the result table, but if you export raw JSON the type wrappers come back. Use$toLong/$toDoublein your pipeline to coerce. - DocumentDB / Azure Cosmos compatibility — both speak the MongoDB wire protocol but with feature gaps (no
$lookupon DocumentDB before 4.0, no transactions in some Cosmos tiers). Stick to documented features for portability.
Example queries
// List collections in the current database
db.getCollectionNames()
// Count documents per status
db.orders.aggregate([
{ $group: { _id: "$status", count: { $sum: 1 } } },
{ $sort: { count: -1 } }
])
Where to go next
For more on writing SQL cells, see SQL cells.