Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to find documents where the field "age" equals 25.
MongoDB
db.collection.find({ "age": { [1]: 25 } }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt or $lt which check greater or less than, not equality.
Using $ne which means not equal.
✗ Incorrect
The $eq operator checks if the field value is equal to the specified value.
2fill in blank
mediumComplete the code to find documents where the "status" field equals "active".
MongoDB
db.collection.find({ "status": { [1]: "active" } }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ne which means not equal.
Using $in which checks if value is in an array.
✗ Incorrect
The $eq operator matches documents where the field equals the given value.
3fill in blank
hardFix the error in the query to find documents where "score" equals 100.
MongoDB
db.collection.find({ "score": { [1]: 100 } }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including the colon inside the blank causing syntax errors.
Using $gt which means greater than.
✗ Incorrect
The correct syntax is $eq followed by a colon and the value, so $eq: 100. Here the colon is outside the blank, so only $eq is needed.
4fill in blank
hardFill both blanks to find documents where "category" equals "books" and "price" equals 20.
MongoDB
db.collection.find({ "category": { [1]: "books" }, "price": { [2]: 20 } }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ne or $gt which do not check for equality.
Mixing different operators for the two fields.
✗ Incorrect
Both fields use $eq to check for equality with the given values.
5fill in blank
hardFill all three blanks to find documents where "type" equals "fruit", "color" equals "red", and "quantity" equals 10.
MongoDB
db.collection.find({ "type": { [1]: "fruit" }, "color": { [2]: "red" }, "quantity": { [3]: 10 } }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ne which means not equal.
Using $exists or $in which check for existence or membership, not equality.
✗ Incorrect
All three fields use $eq to check for equality with their respective values.