Introduction
Dot notation helps you look inside nested parts of your data easily.
Jump into concepts and practice - no test required
Dot notation helps you look inside nested parts of your data easily.
db.collection.find({"outer.inner": value})Use quotes around the field path if it contains special characters.
Dot notation uses a dot (.) to go deeper inside nested documents.
db.users.find({"address.city": "New York"})db.orders.updateOne({"customer.name": "Alice"}, {$set: {"customer.phone": "123-456"}})db.products.find({}, {"details.weight": 1, _id: 0})This query finds all library documents where the book's author's name is John Doe.
db.library.find({"book.author.name": "John Doe"})Dot notation only works with embedded documents, not arrays directly.
If you want to query inside arrays, use special operators like $elemMatch.
Dot notation lets you access nested fields inside documents easily.
Use it to find, update, or project parts of embedded documents.
Remember to use quotes if the field names have special characters.
address.city in MongoDB?{ name: 'Alice', contact: { phone: '1234', email: 'alice@example.com' } } What will the query db.collection.find({ 'contact.phone': '1234' }) return?db.users.updateOne({ name: 'Bob' }, { $set: { address.city: 'Boston' } }){ _id: 1, profile: { name: 'Eve', contacts: { email: 'eve@mail.com', phone: '555' } } } How do you write a query to find documents where the phone number is '555' using dot notation?