MongoDB target
TwinCommit applies changes to MongoDB with bulkWrite upserts. The document _id comes from the source primary key. Each batch and its checkpoint document are written in one multi-document transaction, so delivery is exactly-once.
Supported: MongoDB 6.0, 7.0 and 8.x replica sets and sharded clusters · MongoDB Atlas.
Configuration
Section titled “Configuration”target: type: mongodb uri: mongodb+srv://twincommit:${MONGO_TARGET_PASSWORD}@cluster1.example.mongodb.net/ database: replica id_field: _id # single-column PKs map to _id; composite PKs become an embedded document nest: [] # optional: embed child tables, see belowHow apply works
Section titled “How apply works”- Inserts and updates become
replaceOnewithupsert: true, filtered on_id. - Deletes become
deleteOne. - The batch and the checkpoint document in
state_schemaare committed in one transaction.
Embedding child tables
Section titled “Embedding child tables”Use nest to embed rows from a child table as an array in the parent document:
nest: - parent: SALES.ORDERS child: SALES.ORDER_LINES field: lines join: [ORDER_ID]db.getSiblingDB("admin").createUser({ user: "twincommit", pwd: "********", roles: [{ role: "readWrite", db: "replica" }]})