Documentation Index
Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
Use this file to discover all available pages before exploring further.
Operator-managed MongoDB Connector is available starting with Operator version 0.10.0.
Prerequisites
Before setting up the MongoDB Connector, ensure you have:- Prepared a MongoDB database (see MongoDB Connector prerequisites)
- Deployed a Big Peer using the Ditto Operator (version 0.10.0 or above)
- Created a Big Peer App
Creating a MongoDB Connector
The examples in this guide assume you have followed the quickstart guide and have a Big Peer and App deployed. To create a MongoDB Connector, you can create your connector using theBigPeerDataBridge CRD.
BigPeerDataBridge resources must include both the ditto.live/app: <big-peer-app-name> and ditto.live/big-peer: <big-peer-name> labels.Connection String Options
You can provide the MongoDB connection string in two ways:Option 1: Using a Kubernetes Secret
Option 2: Using AWS Secrets Manager
For cloud deployments, you can reference a secret stored in AWS Secrets Manager:Configuration Options
Collection Mappings
Thecollections section specifies how MongoDB collections are synchronized with Ditto:
Required Fields
fields: List of MongoDB fields to use for creating the Ditto document ID- Can be a single field:
fields: [_id] - Or multiple fields:
fields: [id, locationId] - These fields must be immutable and always present in MongoDB documents
- See ID Mapping Between Systems for details
- Can be a single field:
Optional Fields
-
initialSync: (boolean, default:false)- When
true, syncs pre-existing MongoDB documents to Ditto on first connection - When
false, only syncs new documents created after the connector starts
- When
-
mode: (string, default:"json")"json": Standard JSON representation"ejson": MongoDB Extended JSON format for better type fidelity- See EJSON Mode for details
-
dqlStrictMode: (boolean, default:true)- Controls DQL strict mode for this collection
- Must be
falsewhen using EJSON mode - See DQL Strict Mode for details
Settable Counters
Settable counters allow numeric fields to be incremented or decremented from Ditto while also being directly settable from MongoDB. This is useful applications where backend systems set absolute values while mobile clients increment/decrement. See Settable Counters to learn how and when to use Settable Counters in your applications. To configure settable counters, add thedittoTypes.settableCounters array to your collection configuration:
How It Works
Bidirectional sync behavior:- MongoDB → Ditto: When you update a number field in MongoDB that’s configured as a settable counter, it syncs to Ditto as a settable counter type
- Ditto → MongoDB: Settable counter values materialize as regular numbers in MongoDB
Behavior Notes
- All writes from MongoDB are treated as “reset” operations
- “Reset” wins over increment/decrement in conflict resolution
- You can specify nested paths like
order.qtyfor counters in nested objects
Multiple Collections
You can configure multiple collections in a single connector:Verifying Your Setup
After creating the MongoDB Connector, verify it’s running correctly:Check Pod Status
Running state.
Test Bidirectional Sync
Ditto → MongoDB
Insert a document via the HTTP API:MongoDB → Ditto
Insert a document directly in MongoDB:Troubleshooting
Check Connector Logs
Common Issues
Connection failures: Verify your MongoDB connection string is correct and that network policies allow traffic from your Kubernetes cluster to MongoDB. Document not syncing: Ensure the document includes all fields specified in thefields configuration.
EJSON errors: When using EJSON mode, ensure dqlStrictMode is set to false.
For more troubleshooting guidance, see MongoDB Connector Troubleshooting.