Question 5 / 50
What does it mean that a single-document write in MongoDB is atomic?
Short answer
The whole document is committed or not at all. Readers never see a half-applied update to that document. That is why embedding related fields you must update together is the default way to get atomicity without a multi-document transaction.
Why?
If Rahul's address and status live on the same user document, one updateOne can change both and observers see either the old document or the new one. If the same facts live in two collections, you need a transaction — or you accept a window where they disagree. This is the modelling implication interviewers are after, not the isolation-level textbook.
Interview tip
Connect atomicity to schema: 'I embed so the write I care about stays on one document.'
Common mistake
Assuming collections or queries are atomic. find() is not a snapshot of the whole collection.
How did you do?
Cheat Sheet