Complete the code to find documents where the array 'scores' contains an element with 'score' equal to 100.
db.students.find({"scores.score": [1])The query matches documents where any element in the 'scores' array has a 'score' field equal to 100. The value should be a number, not a string or object.
Complete the code to find documents where the 'scores' array contains an element with 'type' equal to 'exam'.
db.students.find({"scores.type": [1])The value for 'type' is a string, so it must be enclosed in quotes in the query. Using double quotes inside the query is correct.
Fix the error in the query to find documents where the 'scores' array contains an element with 'score' greater than 90.
db.students.find({"scores.score": [1])The correct MongoDB operator for 'greater than' is '$gt'. It must be prefixed with a dollar sign.
Fill both blanks to find documents where the 'scores' array contains an element with 'type' equal to 'quiz' and 'score' less than 50.
db.students.find({"scores": { $elemMatch: {"type": [1], "score": [2] } } })The $elemMatch operator matches array elements that satisfy both conditions: 'type' is the string "quiz" and 'score' is less than 50 using $lt.
Fill all three blanks to find documents where the 'scores' array contains an element with 'type' equal to 'homework', 'score' greater than or equal to 80, and 'score' less than 100.
db.students.find({"scores": { $elemMatch: {"type": [1], "score": [2], "score": [3] } } })The $elemMatch operator matches array elements where 'type' is "homework", 'score' is greater than or equal to 80 ($gte), and less than 100 ($lt).