Including Embedded Documents
Atomicity applies to operations involving embedded documents in a MongoDB document. When modifying or updating embedded documents, MongoDB ensures atomic changes, maintaining consistency throughout the document structure.
{
_id: ObjectId("userId"),
name: "GFG",
age: 10,
scores: [
{ team: "Technical Content Engineer", article: 23 },
{ team: "Python Developer", article: 12 }
]
}
What is Atomicity in MongoDB and How to Achieve it?
Atomicity ensures that all changes within a single operation are either fully completed or not applied at all, preventing data corruption and inconsistencies.
Table of Content
- Atomicity and How to Achieve it
- Operation Example: insertOne()
- Success or Error
- Atomicity on the Document Level
- Including Embedded Documents
- Single Document Operations
- Multi-Document Transactions
Contact Us