MongoDB
Spin up an isolated MongoDB branch of your remote database with mirrord
This page covers DB branching for MongoDB. For the general concepts, the full list of config fields, and how a session behaves, see the DB Branching overview.
Basic Configuration
{
"feature": {
"db_branches": [
{
"id": "users-mongo-db",
"type": "mongodb",
"version": "7.0",
"name": "users-database-name",
"connection": {
"url": "MONGODB_URI"
},
"copy": {
"mode": "empty"
}
}
]
}
}The connection field describes how mirrord locates the source database connection details - a full connection URL or individual parameters (host, port, user, password, database). See Connection Modes for all supported sources, including Kubernetes Secrets, Google Secret Manager, literal values, and composite environment variables.
Copy Modes
MongoDB supports two copy modes. The copy mode sets the default behavior for all collections. When combined with collection filters, the mode determines what happens to collections that are not listed in the filter. Filtered collections always receive only the matching documents.
"empty" (default)
Nothing - an empty database
Workflows where your application initializes the collections or runs migrations as part of startup
"all"
All collections and data from the source database
A full clone of your environment data for debugging or reproducing production-like scenarios
Collection Filters
Developers can customize which collections are copied and apply MongoDB query filters per collection.
The copy mode controls the baseline (what happens to collections not mentioned in your filters):
"empty"
Not created
Created with matching documents only
"all"
Fully copied (all documents)
Copied with matching documents only
Example: "mode": "all" with filters
All collections are copied, but the users collection includes only documents for alice and bob, and the orders collection includes only documents created after the given timestamp.
Example: "mode": "empty" with filters
Only the users collection is created, containing documents for alice and bob. All other collections are not created. This is useful when you only need a subset of reference data and your application handles the rest through migrations.
Last updated
Was this helpful?

