querydrill

Learn › MongoDB fundamentals

Nested objects and arrays

Dot notation, matching array contents, and the trap everyone hits.

By the end: Query inside sub-documents and arrays of objects correctly.

Lessons

4
  1. Dot notation into nested objects

    Query fields inside nested MongoDB objects with dot notation: { "address.city": "Bangalore" }, and why the path needs quotes.

  2. Querying arrays

    How MongoDB matches arrays: a scalar match tests every element, and $all requires all of your values to be present.

  3. Arrays of objects

    Querying arrays of sub-documents in MongoDB with dot notation, and what a match on "orders.status" actually tests.

  4. $elemMatch and the multi-condition trap

    The classic MongoDB array trap: two conditions on an array of objects can match different elements. $elemMatch is the fix.

Drills

3 easy · 1 medium
Start reading →Skip to the drills