Recall & Review
beginner
What is dot notation in MongoDB?
Dot notation is a way to access fields inside embedded documents by using a period (.) to separate the parent and child field names.
Click to reveal answer
beginner
How do you query a nested field called
address.city in MongoDB?You use dot notation like this:
{ 'address.city': 'New York' } to find documents where the city inside the address is 'New York'.Click to reveal answer
intermediate
Why is dot notation useful when working with embedded documents?
It lets you directly access or update nested fields without needing to retrieve or modify the whole embedded document.
Click to reveal answer
intermediate
Example: How to update the
phone field inside an embedded contact document?Use dot notation in the update:
{ $set: { 'contact.phone': '123-456-7890' } } to change only the phone number.Click to reveal answer
advanced
Can dot notation be used to query arrays inside embedded documents?
Yes, dot notation can access fields inside objects within arrays, for example:
{ 'items.0.name': 'Book' } targets the first item's name.Click to reveal answer
How do you access the
zipcode field inside an embedded address document in MongoDB?✗ Incorrect
Dot notation uses a period to access nested fields, so 'address.zipcode' is correct.
Which MongoDB update operator is commonly used with dot notation to change a nested field?
✗ Incorrect
The $set operator updates the value of a field, and with dot notation it can update nested fields.
If you want to find documents where the first item in an array
products has a name of 'Pen', which query is correct?✗ Incorrect
Dot notation with the index '0' accesses the first element in the array.
True or False: Dot notation can only be used for querying, not updating fields.
✗ Incorrect
Dot notation works for both querying and updating nested fields.
What does the query
{ 'profile.age': { $gt: 30 } } do?✗ Incorrect
The $gt operator means 'greater than', so it finds documents with profile.age > 30.
Explain how dot notation helps when working with embedded documents in MongoDB.
Think about how you reach inside a box inside another box.
You got /4 concepts.
Describe how you would update a phone number inside a nested contact document using dot notation.
Remember the syntax for updating nested fields.
You got /3 concepts.