0
0
MongoDBquery~10 mins

$nor 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 neither condition is true using $nor.

MongoDB
db.collection.find({ $nor: [ [1] ] })
Drag options to blanks, or click blank then click option'
A{ age: { $lt: 30 } }
B{ age: { $gt: 30 } }
C{ age: 30 }
D{ age: { $eq: 30 } }
Attempts:
3 left
💡 Hint
Common Mistakes
Using $nor with a single condition that is true instead of false.
Confusing $nor with $or.
2fill in blank
medium

Complete the code to find documents where neither age is less than 25 nor status is 'A'.

MongoDB
db.collection.find({ $nor: [ [1] ] })
Drag options to blanks, or click blank then click option'
A[ { age: { $lt: 25 } }, { status: 'A' } ]
B{ age: { $lt: 25 }, status: 'A' }
C{ age: { $lt: 25 } }, { status: 'A' }
D{ age: { $lt: 25 }, status: { $ne: 'A' } }
Attempts:
3 left
💡 Hint
Common Mistakes
Putting multiple conditions inside one object instead of separate objects in the array.
Not using an array for $nor.
3fill in blank
hard

Fix the error in the query to correctly use $nor with two conditions.

MongoDB
db.collection.find({ $nor: [1] })
Drag options to blanks, or click blank then click option'
A{ age: { $lt: 20 }, status: 'B' }
B[ { age: { $lt: 20 }, status: 'B' } ]
C{ age: { $lt: 20 } }, { status: 'B' }
D[ { age: { $lt: 20 } }, { status: 'B' } ]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single object with multiple conditions instead of an array.
Passing multiple objects separated by commas without an array.
4fill in blank
hard

Fill both blanks to find documents where neither age is greater than 40 nor status is 'C'.

MongoDB
db.collection.find({ $nor: [ [1], [2] ] })
Drag options to blanks, or click blank then click option'
A{ age: { $gt: 40 } }
B{ age: { $lt: 40 } }
C{ status: 'C' }
D{ status: 'B' }
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up greater than and less than operators.
Using wrong status values.
5fill in blank
hard

Fill all three blanks to find documents where none of these are true: age less than 18, status 'D', or score greater than 90.

MongoDB
db.collection.find({ $nor: [ [1], [2], [3] ] })
Drag options to blanks, or click blank then click option'
A{ age: { $lt: 18 } }
B{ status: 'D' }
C{ score: { $gt: 90 } }
D{ score: { $lt: 90 } }
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators for score.
Not separating conditions into individual objects.