Skip to content
Justice Tech School

Querying Nested Documents

Use dot notation to reach into embedded documents and arrays by position. Quote the key.

Example
db.users.find({ "address.city": "Lagos" })
db.users.find({ "scores.0": { $gt: 90 } })

Exercise

Reach into address.

{ "address.": "Lagos" }

Quiz Test

How do you query a nested field?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.