0
0
MongoDBquery~10 mins

Comparison expressions ($eq, $gt in aggregation) in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to match documents where the field 'score' equals 10.

MongoDB
{ $match: { score: { $[1]: 10 } } }
Drag options to blanks, or click blank then click option'
A$eq
B$ne
C$lt
D$gt
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt instead of $eq will match values greater than 10, not equal.
Using $ne will match values not equal to 10.
2fill in blank
medium

Complete the code to match documents where the field 'age' is greater than 25.

MongoDB
{ $match: { age: { $[1]: 25 } } }
Drag options to blanks, or click blank then click option'
A$lt
B$gt
C$eq
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Using $eq will only match values equal to 25, not greater.
Using $lt will match values less than 25.
3fill in blank
hard

Fix the error in the code to correctly match documents where 'price' is greater than 100.

MongoDB
{ $match: { price: { $gt$[1] 100 } } }
Drag options to blanks, or click blank then click option'
A=
B,
C:
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas or equal signs instead of colon causes syntax errors.
4fill in blank
hard

Fill both blanks to match documents where 'quantity' equals 5 and 'status' is greater than 2.

MongoDB
{ $match: { quantity: { $[1]: 5 }, status: { $[2]: 2 } } }
Drag options to blanks, or click blank then click option'
A$eq
B$gt
C$lt
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the operators or using wrong ones like $lt or $ne.
5fill in blank
hard

Fill all three blanks to create a $match stage that finds documents where 'score' equals 90, 'age' is greater than 18, and 'level' equals 3.

MongoDB
{ $match: { score: { $[1]: 90 }, age: { $[2]: 18 }, level: { $[3]: 3 } } }
Drag options to blanks, or click blank then click option'
A$eq
B$gt
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ne instead of $eq or mixing up operators.