MongoDB
SoftDB supports MongoDB with multi-database browsing, collection exploration, schema inference from sampled documents, a native JSON Schema Validation editor, and a JSON-based query interface.
Quick Setup
Section titled “Quick Setup”-
Open the Connection Hub and click New Connection.
-
Select MongoDB as the database type.
-
For a local server, fill in:
- Host:
localhost - Port:
27017 - Database: optional — leave blank to browse all databases
- Host:
-
For MongoDB Atlas or any
mongodb+srv://connection, toggle Use URI and paste your full connection string. -
Click Test Connection, then Save.
Connection Settings
Section titled “Connection Settings”| Field | Default | Notes |
|---|---|---|
| Host | localhost | MongoDB server hostname or IP |
| Port | 27017 | Standard MongoDB port |
| Username | — | Optional for local servers without auth |
| Password | — | Stored encrypted |
| Database | — | Optional. Leave blank to browse all databases |
| URI | — | Full connection string (URI mode only) |
URI Mode for Atlas
Section titled “URI Mode for Atlas”Toggle Use URI to enter a full MongoDB connection string. This is the recommended approach for MongoDB Atlas:
mongodb+srv://username:password@cluster0.abc123.mongodb.net/mydb?retryWrites=true&w=majorityWhen using URI mode, the host, port, username, password, and database fields are ignored. SoftDB parses the database name from the URI path if present.
Multi-Database Browsing
Section titled “Multi-Database Browsing”When you leave the Database field blank, SoftDB calls listDatabaseNames and filters out system databases (admin, local, config). The sidebar shows a three-level tree:
Connection└── my_app ├── users ├── orders └── products└── analytics └── eventsClicking a collection opens it in the table explorer. SoftDB samples up to 100 documents to infer the collection’s field names and BSON types.
JSON Command Syntax
Section titled “JSON Command Syntax”The basic structure is:
{ "collection": "users", "action": "find", "filter": {}, "limit": 100}If you omit action, it defaults to find.
Supported actions
Section titled “Supported actions”| Action | Description |
|---|---|
find | Query documents with optional filter, limit, and skip |
count | Count documents matching a filter |
insert | Insert a single document |
delete | Delete documents matching a filter |
updateOne | Update the first matching document |
updateMany | Update all matching documents |
aggregate | Run an aggregation pipeline |
distinct | Get distinct values for a field |
createIndex | Create an index on a collection |
dropIndex | Drop a named index |
explain | Get the query execution plan |
Query Examples
Section titled “Query Examples”Find with filter
Section titled “Find with filter”{ "collection": "users", "action": "find", "filter": { "age": { "$gt": 25 } }, "limit": 10}Count documents
Section titled “Count documents”{ "collection": "orders", "action": "count", "filter": { "status": "pending" }}Aggregation pipeline
Section titled “Aggregation pipeline”{ "collection": "orders", "action": "aggregate", "pipeline": [ { "$match": { "status": "completed" } }, { "$group": { "_id": "$customer_id", "total": { "$sum": "$amount" } } }, { "$sort": { "total": -1 } }, { "$limit": 10 } ]}Update documents
Section titled “Update documents”{ "collection": "users", "action": "updateMany", "filter": { "plan": "free" }, "update": { "$set": { "trial_expires": null } }}Insert a document
Section titled “Insert a document”{ "collection": "products", "action": "insert", "document": { "name": "Widget Pro", "price": 29.99, "tags": ["hardware", "featured"] }}Distinct values
Section titled “Distinct values”{ "collection": "orders", "action": "distinct", "field": "status"}Batch queries
Section titled “Batch queries”You can run multiple queries in one execution by wrapping them in a JSON array. Results are merged into a single result set with a __collection__ column added:
[ { "collection": "users", "action": "count" }, { "collection": "orders", "action": "count" }]Schema Inference
Section titled “Schema Inference”SoftDB doesn’t require a fixed schema for MongoDB collections. When you open a collection, it samples up to 100 documents and infers field names and BSON types. The inferred schema appears in the sidebar column list and is used for AI autocomplete suggestions.
BSON types are mapped to readable names: string, int, long, double, bool, object, array, objectId, date, timestamp, decimal, binData, regex, and null.
JSON Schema Validation Editor
Section titled “JSON Schema Validation Editor”Each collection can have a JSON Schema validator that MongoDB enforces on insert and update. SoftDB includes a dedicated editor for this:
- Open a collection in the table explorer.
- Click the Schema tab (or the schema icon in the toolbar).
- Edit the JSON Schema in the Monaco editor.
- Click Apply to save the validator to MongoDB.
SoftDB applies validators with validationLevel: "moderate" and validationAction: "warn" by default, so existing documents that don’t match the schema won’t cause errors — only new writes are checked.
Troubleshooting
Section titled “Troubleshooting”Connection refused
Section titled “Connection refused”failed to ping mongodb: server selection error: ... connection refusedMongoDB isn’t running, or it’s listening on a different port. Check with systemctl status mongod or brew services list. Verify the port in /etc/mongod.conf.
Authentication failed
Section titled “Authentication failed”failed to ping mongodb: (AuthenticationFailed) Authentication failedWrong username or password, or the user doesn’t exist in the admin database. Check your credentials and ensure the user has the right roles.
Atlas connection string format
Section titled “Atlas connection string format”Atlas connection strings use mongodb+srv:// and require the Use URI toggle. The standard host:port fields don’t work for Atlas. Copy the connection string from the Atlas dashboard (Connect > Drivers) and paste it into the URI field.
Make sure your IP address is in the Atlas IP Access List, and that the database user has the correct permissions.