0
0
MongoDBquery~10 mins

$ne for not equal 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 'status' is not equal to 'active'.

MongoDB
db.collection.find({ status: { [1]: "active" } })
Drag options to blanks, or click blank then click option'
A$ne
B$eq
C$gt
D$in
Attempts:
3 left
💡 Hint
Common Mistakes
Using $eq instead of $ne.
Using $in which checks for inclusion in an array.
Using $gt which checks for greater than.
2fill in blank
medium

Complete the code to find documents where the 'age' field is not equal to 30.

MongoDB
db.users.find({ age: { [1]: 30 } })
Drag options to blanks, or click blank then click option'
A$gte
B$lt
C$eq
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gte or $lt which are comparison operators but not 'not equal'.
Using $eq which means equal, not not equal.
3fill in blank
hard

Fix the error in the query to find documents where 'category' is not 'books'.

MongoDB
db.products.find({ category: [1] })
Drag options to blanks, or click blank then click option'
A$ne:
B{ $ne: }
C{ $ne: "books" }
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Writing $ne without curly braces.
Using $ne without a colon or value.
Placing $ne outside an object.
4fill in blank
hard

Fill both blanks to find documents where 'status' is not 'pending' and 'priority' is not 1.

MongoDB
db.tasks.find({ status: { [1]: "pending" }, priority: { [2]: 1 } })
Drag options to blanks, or click blank then click option'
A$ne
B$eq
C$gt
D$lt
Attempts:
3 left
💡 Hint
Common Mistakes
Using $eq which means equal, not not equal.
Mixing different operators like $gt or $lt which check greater or less than.
5fill in blank
hard

Fill all three blanks to find documents where 'type' is not 'admin', 'score' is not 100, and 'active' is not false.

MongoDB
db.users.find({ type: { [1]: "admin" }, score: { [2]: 100 }, active: { [3]: false } })
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 $eq which means equal, not not equal.
Using $gt or $lt which check greater or less than, not inequality.