Embedding

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: Schema patterns

What it does

Keeps commonly co-read data together and can enable single-document atomic updates.

Syntax

Place bounded related data inside parent

Use case

Settings, bounded addresses, order snapshots.

Embedding: practical example
{ _id: orderId, shippingAddress: { city: "Bengaluru", postalCode: "560001" } }
💡 Explanation Keeps commonly co-read data together and can enable single-document atomic updates. When to use it Settings, bounded addresses, order snapshots.
Key Takeaways
  • Keeps commonly co-read data together and can enable single-document atomic updates.
  • Typical use: Settings, bounded addresses, order snapshots.