0
0
MongoDBquery~10 mins

$eq for equality 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 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'
A$ne
B$eq
C$lt
D$gt
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt or $lt which check greater or less than, not equality.
Using $ne which means not equal.
2fill in blank
medium

Complete 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'
A$eq
B$ne
C$in
D$exists
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ne which means not equal.
Using $in which checks if value is in an array.
3fill in blank
hard

Fix 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'
A$eq
B$gt
C$eq:
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Including the colon inside the blank causing syntax errors.
Using $gt which means greater than.
4fill in blank
hard

Fill 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'
A$eq
B$ne
C$gt
D$lt
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ne or $gt which do not check for equality.
Mixing different operators for the two fields.
5fill in blank
hard

Fill 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'
A$ne
B$eq
C$exists
D$in
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ne which means not equal.
Using $exists or $in which check for existence or membership, not equality.