Introduction
Use $eq to find documents where a field exactly matches a value. It helps you get only the data you want.
Jump into concepts and practice - no test required
{ field: { $eq: value } }{ age: { $eq: 30 } }{ status: { $eq: "active" } }{ score: { $eq: 100 } }db.users.find({ age: { $eq: 25 } })$eq operator do in a MongoDB query?$eq$eq operator is used to filter documents where a field exactly matches a given value.$eq.$eq means equality match [OK]age equals 30 using $eq?$eq as key and the value to match as value: { age: { $eq: 30 } }.users with documents:{ "name": "Alice", "age": 25 }, { "name": "Bob", "age": 30 }, { "name": "Carol", "age": 30 }db.users.find({ age: { $eq: 30 } }) return?age equals 30.age 30, so both documents match and will be returned.db.products.find({ price: $eq: 100 }) but it gives an error. What is wrong?$eq operator must be inside an object as the value for the field key, like { price: { $eq: 100 } }.$eq: 100, causing a syntax error.$eq: 100 value -> Option Borders where the status is exactly "shipped" and the quantity is 10. Which query correctly uses $eq for both conditions?$eq operator inside an object: { status: { $eq: "shipped" } } and { quantity: { $eq: 10 } }.