MongoDB ondersteunt multi-document ACID-transacties (sinds v4.0 voor replica sets, v4.2 voor sharded clusters) — het groeperen van bewerkingen over meerdere documenten/collecties zodat ze allemaal slagen of allemaal mislukken. Echter, het documentmodel van MongoDB maakt transacties vaak onnodig door atomaire single-document-bewerkingen.
Single-document-bewerkingen zijn al atomair
KEY POINT: operations on a SINGLE document are ALWAYS atomic in MongoDB.
→ Because related data is often EMBEDDED in one document, many operations that would
need a transaction in SQL are a single atomic document update in MongoDB.
→ Good schema design (embedding) often eliminates the NEED for multi-doc transactions.
