Complete the code to find documents where the nested field 'address.city' is 'New York'.
db.users.find({"address.[1]": "New York"})The nested field 'address.city' is accessed using dot notation as 'address.city'. So the blank should be filled with 'city'.
Complete the code to find documents where the nested array 'orders.items' contains 'apple'.
db.orders.find({"orders.[1]": "apple"})To query an array field inside 'orders', we use 'orders.items'. So the blank should be 'items'.
Fix the error in the query to find documents where 'profile.age' is greater than 30.
db.users.find({"profile.age": { [1]: 30 }})The operator '$gt' means 'greater than'. To find ages greater than 30, use '$gt'.
Fill both blanks to find documents where 'comments.rating' is at least 4 and 'comments.approved' is true.
db.posts.find({"comments.rating": { [1]: 4 }, "comments.approved": [2] })'$gte' means 'greater than or equal to', so it fits for rating at least 4. The approved field should be true, so use 'true'.
Fill all three blanks to create a projection that includes 'name', excludes '_id', and includes nested field 'profile.email'.
db.users.find({}, { [1]: 1, [2]: 0, [3]: 1 })To include 'name' and 'profile.email', set them to 1. To exclude '_id', set it to 0.