Skip to main content

Connecting to MongoDB Atlas

MongoDB Atlas uses SRV connection strings. Enter your Atlas cluster hostname (e.g. cluster0.abc123.mongodb.net) as the host. Cobi detects the SRV pattern automatically and handles the port for you.

Connecting to a Self-Hosted MongoDB

Enter your server’s hostname or IP address and port (27017 by default).

Schema Conventions

Cobi maps MongoDB collections to SQL tables. Keep the following in mind when chatting with the Data Assistant:
ConventionDetail
CollectionsEach collection appears as a table
_id fieldPresent on every document as a unique identifier, used as the primary key
Nested fieldsFlattened with underscores, so address.city becomes address_city
ArraysArray fields are queryable. Ask the Data Assistant to expand or filter them
RelationshipsMongoDB has no foreign keys. Reference related collections by matching field values

Create a Read-Only User

Self-hosted MongoDB: run the following in mongosh:
use admin
db.createUser({
  user: "cobi_reader",
  pwd: "secure_password",
  roles: [{ role: "read", db: "your_database" }]
})
MongoDB Atlas: create the user in the Atlas UI under Database Access, with the built-in read role scoped to your database.

Troubleshooting

See the Troubleshooting page for help with connection issues.