Complete the code to find documents where the nested field 'address.city' equals 'Paris'.
db.users.find({"address[1]city": "Paris"})In MongoDB, nested fields are accessed using dot notation. So to query the city inside address, use 'address.city'.
Complete the code to find documents where the nested field 'profile.details.age' is greater than 30.
db.users.find({"profile.details.age": { [1]: 30 }})The operator '$gt' means 'greater than' in MongoDB queries. It filters documents where the field value is greater than the specified number.
Fix the error in the query to find documents where 'settings.notifications.email' is true.
db.users.find({"settings[1]notifications[1]email": true})To access nested fields at any depth, MongoDB requires dot notation between each level. So use '.' between 'settings', 'notifications', and 'email'.
Fill both blanks to query documents where 'profile.contacts.phone.mobile' exists and is not null.
db.users.find({"profile[1]contacts[2]phone.mobile": { $exists: true, $ne: null } })Use dot notation '.' between each nested field to correctly access 'profile.contacts.phone.mobile'.
Fill all three blanks to query documents where 'settings.preferences.theme.color' equals 'dark'.
db.users.find({"settings[1]preferences[2]theme[3]color": "dark"})Dot notation '.' is used to access nested fields at any depth in MongoDB queries.