Complete the code to find documents where the 'scores' array has an element greater than 80.
db.students.find({ scores: { [1]: { score: { $gt: 80 } } } })The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria.
Complete the code to find documents where the 'grades' array has an element with 'score' greater than 85 and 'type' equal to 'exam'.
db.records.find({ grades: { $elemMatch: { score: { [1]: 85 }, type: 'exam' } } })The $gt operator means 'greater than'. Here it checks if the 'score' field in any element is greater than 85.
Fix the error in the query to find documents where 'items' array has an element with 'price' less than 50 and 'qty' greater than 10.
db.orders.find({ items: { [1]: { price: { $lt: 50 }, qty: { $gt: 10 } } } })The $elemMatch operator is needed to match documents where an array element satisfies multiple conditions together.
Fill both blanks to find documents where 'reviews' array has an element with 'rating' at least 4 and 'verified' is true.
db.products.find({ reviews: { [1]: { rating: { [2]: 4 }, verified: true } } })$elemMatch matches array elements with multiple conditions. $gte means 'greater than or equal to', used here for rating at least 4.
Fill all three blanks to find documents where 'logs' array has an element with 'status' equal to 'error', 'code' greater than 500, and 'retry' false.
db.system.find({ logs: { [1]: { status: [2], code: { [3]: 500 }, retry: false } } })$elemMatch matches array elements with multiple conditions. The status must be the string 'error'. The code must be greater than 500 using $gt.