midMongoDB
How does MongoDB handle transactions?
Updated May 1, 2026
Short answer
MongoDB supports multi-document ACID transactions since version 4.0.
Deep explanation
Transactions allow you to group multiple operations. If one fails, the whole set is rolled back. They work across replica sets and sharded clusters.
Real-world example
Transferring money between two user accounts (debit one, credit another).
Common mistakes
- Using transactions for everything, which can severely impact performance.
Follow-up questions
- What is the default transaction timeout?