MongoDB adapter
The MongoDB adapter works with:
- MongoDB 5.0+
- MongoDB Atlas (all tiers including M0 free)
- AWS DocumentDB (Mongo 5.0-compatible)
- Azure Cosmos DB for MongoDB (4.2+ API)
- Self-hosted MongoDB
Config shape
{ "type": "mongodb", "config": { "uri": "mongodb+srv://spelo_ro:pass@cluster0.xxxxx.mongodb.net/?retryWrites=true", "database": "production", "tls": true }, "collections": { "products": { "source": "products", "searchable_fields": ["name", "description", "sku"], "filterable_fields": ["category", "price", "in_stock", "tags"], "display_fields": ["_id", "name", "price", "sku"] } }}Setup
-
Create a read-only database user
In Atlas: Database Access → Add New Database User → Built-in Role: Only read any database (or a custom role scoped to your DB).
For self-hosted:
use admindb.createUser({user: 'spelo_ro',pwd: 'StrongRandom123!',roles: [{ role: 'read', db: 'production' }]}) -
Whitelist Spelo’s IPs
Atlas: Network Access → Add IP Address → paste Spelo’s egress CIDRs from spelo.ai/security/ips.
-
Enable TLS
Atlas is TLS-always. Self-hosted: set up
mongodwithtls: requireTLSand set"tls": truein the config. -
Paste the connection URI and database name in the dashboard
Dashboard → Data → MongoDB → Test connection.
-
Map collections — the
sourceis the Mongo collection name (case-sensitive).
Operator translation
| SearchParams operator | MongoDB filter expression |
|---|---|
eq | { field: value } |
neq | { field: { $ne: value } } |
gt | { field: { $gt: value } } |
gte | { field: { $gte: value } } |
lt | { field: { $lt: value } } |
lte | { field: { $lte: value } } |
contains (string column) | { field: { $regex: escapedValue, $options: 'i' } } |
contains (array column) | { field: value } (matches if value ∈ array) |
in | { field: { $in: values } } |
free-text query | $or across searchable_fields with case-insensitive regex |
Security notes
- Collection names validated against
^[A-Za-z_][A-Za-z0-9_]*$— no$or.allowed in names (prevents operator injection). - Regex values are escaped via
\Q...\E-equivalent replacement so a filter value cannot inject regex metacharacters. - Only
find().filter().sort().limit()pipelines are emitted. Noupdate,delete,aggregatewith$out,$merge.
Atlas Data API
The Atlas Data API (HTTPS, no driver) is not used by this adapter. If you want to avoid managing a Mongo driver on our side, the REST adapter can call the Data API directly.
Troubleshooting
Authentication failed→ wrong user/password, or the user isn’t authorized on the target database.ENOTFOUND cluster0.xxxxx.mongodb.net→ DNS issue; make sure the URI is correct (Atlas usesmongodb+srv://).Server selection timed out→ IP not whitelisted in Atlas Network Access.MongoNotConnectedError→ TLS config mismatch. Atlas requirestls: true.- Regex-based search is slow → add a text index or use a real search service.
More: Database connection errors.