Is MongoDB ACID Compliant? — Interview Answer — MongoDB Technical Interview Questions & Answers
Model answer covering single vs multi-document guarantees.
Is MongoDB ACID Compliant? — Interview Answer
- Model answer: Single-document operations are ACID. Multi-document ACID needs an explicit transaction (replica set).
- Do not claim Mongo has no ACID at all — that is outdated for modern versions.
Technical Interview Tip: Be precise: document vs multi-document.
Code Examples for Is MongoDB ACID Compliant? — Interview Answer
Is MongoDB ACID Compliant? — Interview Answer — working example
// mongosh / driver-style multi-document transaction (replica set / mongos required)
session = db.getMongo().startSession()
session.startTransaction()
try {
const users = session.getDatabase("prep_pilot").users
const accounts = session.getDatabase("prep_pilot").accounts
users.updateOne({ email: "ada@example.com" }, { $inc: { points: -10 } })
accounts.updateOne({ email: "ada@example.com" }, { $inc: { balance: 10 } })
session.commitTransaction()
} catch (e) {
session.abortTransaction()
throw e
} finally {
session.endSession()
}Is MongoDB ACID Compliant? — Interview Answer — multi-document ACID transactions need a replica set (or sharded cluster) and a session.
How to Explain Is MongoDB ACID Compliant? — Interview Answer to an Interviewer
Is MongoDB ACID?
Yes for a single document Multi-document via transactions