Multi-document transactions arrived in June, and the interesting question is what their existence says about the schemas that wanted them.
const session = client.startSession();
await session.withTransaction(async () => {
await orders.insertOne({ _id: id, total }, { session });
await stock.updateOne({ sku }, { $inc: { qty: -1 } }, { session });
});
// available on a replica set only — a standalone mongod cannot
A document model that needs a transaction across two collections is usually a model that wanted those two things in one document, which is the entire premise. Where the split is genuinely correct — a ledger and a balance — the transaction is the right tool and carries a real cost in latency and in write conflicts under contention. Reaching for it because a relational habit says to is how a document store ends up with the disadvantages of both models.