0
0
MongoDBquery~10 mins

$not operator behavior 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' is NOT equal to 30.

MongoDB
db.collection.find({ age: { $not: { $eq: [1] } } })
Drag options to blanks, or click blank then click option'
A25
Btrue
C30
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using $not without a condition inside, like { $not: 30 } which is invalid.
Confusing $not with $ne (not equal).
2fill in blank
medium

Complete the code to find documents where the 'status' field does NOT start with the letter 'A'.

MongoDB
db.collection.find({ status: { $not: { $regex: /^[1]/ } } })
Drag options to blanks, or click blank then click option'
AZ
BA
CB
Da
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'a' when the data is uppercase 'A' (case sensitive).
Not using the caret ^ to specify start of string.
3fill in blank
hard

Fix the error in the query to find documents where 'score' is NOT greater than 50.

MongoDB
db.collection.find({ score: { $not: { $gt: [1] } } })
Drag options to blanks, or click blank then click option'
A60
B40
C30
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number other than 50 inside $gt changes the meaning.
Trying to use $not: 50 directly, which is invalid.
4fill in blank
hard

Fill both blanks to find documents where 'category' is NOT 'electronics' and 'price' is NOT less than 100.

MongoDB
db.collection.find({ category: { $not: { $eq: "[1]" } }, price: { $not: { $lt: [2] } } })
Drag options to blanks, or click blank then click option'
Aelectronics
Bbooks
C100
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the price threshold value.
Using $ne instead of $not with $eq or $lt.
5fill in blank
hard

Fill all three blanks to find documents where the 'name' field does NOT contain 'Pro', 'rating' is NOT equal to 5, and 'stock' is NOT less than 10.

MongoDB
db.collection.find({ name: { $not: { $regex: [1] } }, rating: { $not: { $eq: [2] } }, stock: { $not: { $lt: [3] } } })
Drag options to blanks, or click blank then click option'
A/Pro/
B5
C10
D/Pro/i
Attempts:
3 left
💡 Hint
Common Mistakes
Using case-sensitive regex when case-insensitive is needed.
Mixing up the numeric values for rating and stock.