DBX

MongoDB Workspace

The MongoDB workspace is organized around databases, collections, documents, indexes, and GridFS instead of forcing documents into a relational model. It provides both a grid and full JSON view while preserving Extended JSON types such as ObjectId, dates, and long integers.

Connections and Drivers

Use a standard mongodb:// or mongodb+srv:// connection string and include replica set, authentication database, TLS, and other parameters in the URL when needed. Atlas, replica sets, and direct deployments share the same connection entry point.

DBX prefers the native MongoDB path. When a server or authentication protocol requires the older driver, you can select or automatically fall back to the mongodb-legacy Agent. The legacy path may expose fewer administration and mutation capabilities.

Databases and Collections

The object tree can:

  • List databases, collections, indexes, and GridFS buckets
  • Show document count, size, and other available collection statistics
  • Create, rename, or drop collections when using the writable native path
  • Drop databases, one index, or all deletable indexes except _id_
  • Open a document browser or query editor from a collection

Rename and destructive operations show the target and request preview and remain subject to read-only and production protection.

Document Browsing and Pagination

The document browser supports:

  • Paged reads with an estimated total
  • Grid and full-document views
  • Top-level and nested fields such as address.city
  • Searchable field selection, hidden columns, and persistent column layout
  • Quick filters plus multiple field conditions
  • Database-side sorting and collection queries

MongoDB totals may be estimated. In actively changing collections, the count and final page can shift while browsing.

Filters and Commands

Build field filters in the document browser or use shell-style commands in a MongoDB query tab. A date filter value accepts 2025-04-01 19:46:03 or 2025-04-01 as well as RFC 3339; text without a time zone is read in your local zone. Completion can suggest databases, collections, fields, query operators, update operators, aggregation stages, and cursor methods.

Examples:

db.users.find({ status: "active" }).sort({ createdAt: -1 })
db.orders.aggregate([
  { $match: { status: "paid" } },
  { $group: { _id: "$customerId", total: { $sum: "$amount" } } }
])

Use use <database> to switch the MongoDB query context. The database name is completed after use and inside db.getSiblingDB("…").

Grid Editing

The grid expands common fields into columns and supports:

  • Editing top-level or nested fields
  • Adding and removing fields
  • Creating, cloning, and deleting documents
  • Copying selected documents as JSON, Markdown, or MongoDB Shell statements
  • Excluding _id when copying a new-document template
  • Reviewing pending update or delete targets before saving

Collections with very different document shapes are better handled in the full-document view so hidden fields are not overlooked.

Query Result Editing

A query tab result grid is editable when a single find or findOne runs without a projection and returns _id. There you can edit fields and delete rows, review the pending updateOne and deleteOne statements before saving, and the grid reloads after a deletion. Inserting rows is not available; use insertOne or the document browser instead. Aggregations, projected queries, and multi-command scripts stay read-only because their rows cannot be mapped back to single documents.

JSON Document Editing

Document details can switch between a field tree and full JSON source:

  • Paste complete JSON when creating a document
  • Validate JSON syntax and root-object structure before save
  • Format, collapse, and copy nested objects or arrays
  • Preserve Extended JSON such as $oid, $date, and $numberLong
  • Change _id by creating the new document and removing the old one
  • Save full JSON with whole-document replacement semantics
Whole-document replacement writes the complete object back. Verify that the JSON contains every field that must be retained, especially in collections with concurrent updates.

Indexes

The object tree and collection structure can show index name, fields, uniqueness, and other metadata. When the native driver supports it, you can drop one index, drop all deletable indexes, or manage indexes through structure actions.

MongoDB preserves _id_, and sharding or other server rules may protect additional indexes. The server response is authoritative.

GridFS

The GridFS workspace manages buckets and files:

  • Browse, create, and delete buckets
  • Upload, download, preview, and delete files
  • Inspect filename, size, upload time, chunks, and metadata
  • Filter and sort files by fields
  • Export file lists or metadata

Dropping a bucket removes its files and chunks. Verify the bucket name and backup before doing this in production.

Import and Export

Collection documents have dedicated CSV/JSON/NDJSON and BSON import/export workflows. This is separate from relational Table Import: each CSV row becomes a document, nested values stay nested, and BSON dumps preserve native BSON types.

Import data

  1. Right-click a collection and choose Import data.
  2. Choose the format explicitly, then select a .csv, .json, .ndjson/.jsonl, .bson, or .bson.gz file. Desktop reads the local path; Web uploads it to a temporary server file. Changing the file does not override the selected format.
  3. Review the preview. Text formats expose encoding and type settings; CSV supports per-column type overrides. BSON imports do not apply CSV text conversions.
  4. Confirm append-only insert. Duplicate _id values stop the import. Batches that already committed are not rolled back.

CSV follows MongoDB Compass: a header row, nested fields as dotted paths (address.city), array indices (tags[0], matrix[0][1]), ObjectId as 24-character hex, dates as ISO-8601, and empty cells as null. Import samples the first 1000 rows to infer column types; _id hex is restored as ObjectId, and recognizeObjectIdHex extends this to other columns. JSON/NDJSON use Extended JSON ($oid, $date). All strings keeps every cell as text.

CSV type fidelity: Double exports and reimports as Decimal128 (lossless for decimal text). Non-_id ObjectId fields round-trip as String unless recognizeObjectIdHex is on. Small Int64 may narrow to Int32; ISO-date-looking strings become DateTime. Extended JSON types ($binary, $regularExpression, $timestamp, $minKey, $maxKey, $code) round-trip through JSON-text cells. Empty array [] and empty object {} round-trip correctly.

Collection-import limits: append only (no truncate or upsert), CSV export discovers fields from the first 10000 documents (later fields are silently dropped; use NDJSON or BSON for variable schemas), no JSON-array export format, no Excel/GridFS import, and no automatic retry of failed batches. Collection-level BSON import restores documents only, not the companion metadata or indexes.

Export data

  • Right-click a collection and choose Export data, then CSV, NDJSON, BSON, or gzip BSON. This opens the save-file dialog immediately, the same as table export.
  • CSV writes nested objects as dotted columns (address.city) and arrays as indexed columns (tags[0], tags[1]). NDJSON writes one canonical Extended JSON document per line.
  • Collections with more than 256 distinct fields should use NDJSON or BSON.

Database backups

Right-click a database and choose Back up database or Restore database. Database backups include selected collections, collection options, indexes and views. Both the native driver and the mongodb-legacy Agent are supported; the Agent path needs a current Agent build (find-cursor support) so BSON types survive the transfer.

  • Desktop supports the official dump directory layout and MongoDB archive format, optionally gzip-compressed. Web exports archive files and restores either archives or uploaded directories.
  • A dump directory contains <database>/<collection>.bson and .metadata.json, or their .gz variants. MongoDB archive is a separate stream format, not ZIP or tar.
  • Choose the format and gzip option explicitly. For directory restore, Read backup reads the catalog and metadata; selected data files are uploaded only after confirming the source database, target database and collections.
  • Restore reads and writes data in one pass. Optional objcheck validates each BSON document in that same pass and defaults off. Framing, gzip and archive checksum checks remain enabled.
  • Restore appends by default. Drop selected target collections before restoring deletes and recreates only those collections. Existing _id values can cause E11000; failures or cancellation do not roll back earlier writes.
  • Web uploads use the shared DBX_MAX_UPLOAD_MB server setting. Desktop reads local files without an HTTP upload.

These formats interoperate with mongodump/mongorestore for supported collections. Oplog replay, point-in-time guarantees, UUID preservation, internal databases, time-series collections and encrypted collections are outside this workflow; use the official tools for those cases.

Copy the current document, selected documents, or field values as plain JSON or Extended JSON from the grid when you only need the visible selection.

Safety and Compatibility Boundaries

  • Read-only connections block document, field, index, collection, database, and GridFS mutations
  • Production protection requires confirmation before recognizable writes
  • MCP Data read/write permits only scoped MongoDB mutations; opaque or effectively unbounded filters are high risk
  • The legacy Agent may not support native collection and index administration
  • Atlas permissions, authentication database, TLS, and IP allowlists are enforced by MongoDB
  • Paginated totals may be estimates and should not be treated as strongly consistent counts