Single-document atomicity
standardintermediateA write to one document — even one that touches several nested fields and array elements at once — is always all-or-nothing. No other operation ever sees the document half-updated, and multi-document transactions exist for exactly the cases this guarantee does not cover.
Think of it as
This is the guarantee MongoDB gives you for free, on every write, without asking for it. Transactions exist to extend that same all-or-nothing guarantee across more than one document — understanding what is already atomic is what tells you whether you actually need one.
What we're doing: Show one update touching several fields atomically, versus two separate calls that are not atomic with each other.
- 2
- Both the balance change and the history entry land together, in one atomic operation — no reader ever sees one without the other.
- 8
- These are two separate atomic operations back to back — a crash or a concurrent read between them could observe the balance already debited but no history entry yet.
Why this works: Single-document atomicity is defined per write call, not per logical unit of work — combining related changes into one update call is what earns the atomicity, splitting them into two calls loses it even against the same document.
Remember: One write call to one document is always atomic, however many fields it touches — but two separate calls are two atomic operations, not one, even against the same document.
See also: multi document transactions · single document writes are atomic

