Recall & Review
beginner
What does the
$gt operator do in MongoDB?The $gt operator finds documents where the value of a field is greater than a specified value.
Click to reveal answer
beginner
How is
$gte different from $gt in MongoDB?$gte means greater than or equal to, so it includes the specified value itself, while $gt means strictly greater than.
Click to reveal answer
beginner
Write a MongoDB query to find all products with a price greater than 100.
{ price: { $gt: 100 } }Click to reveal answer
beginner
Write a MongoDB query to find all users with age greater than or equal to 18.
{ age: { $gte: 18 } }Click to reveal answer
beginner
If you want to include the value 50 in your search for values greater than or equal to 50, which operator should you use?
You should use $gte because it includes the value itself (50) and all values greater than 50.
Click to reveal answer
Which MongoDB operator finds documents where a field is strictly greater than a value?
✗ Incorrect
$gt means greater than, excluding the value itself.
What does
{ age: { $gte: 21 } } find?✗ Incorrect
$gte means greater than or equal to, so it includes 21 and above.
Which query finds products priced more than 50 but not including 50?
✗ Incorrect
$gt excludes the value 50 itself.
If you want to find all records with a score at least 75, which operator do you use?
✗ Incorrect
$gte means greater than or equal to, so it includes 75.
True or False:
$gt includes the value you compare against.✗ Incorrect
$gt excludes the value itself; it only matches strictly greater values.
Explain the difference between
$gt and $gte in MongoDB queries.Think about whether the value you compare against is included or not.
You got /4 concepts.
Write a MongoDB query to find all documents where the field 'score' is greater than or equal to 90.
Use the $gte operator inside the field object.
You got /4 concepts.