0
0
MongoDBquery~10 mins

Implicit AND with multiple conditions 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 age is 25 and city is 'New York'.

MongoDB
db.users.find({ age: 25, city: [1] })
Drag options to blanks, or click blank then click option'
A'Los Angeles'
B'New York'
C'Chicago'
D'Miami'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the city name.
Using $and operator unnecessarily.
2fill in blank
medium

Complete the code to find documents where status is 'active' and score is greater than 80.

MongoDB
db.players.find({ status: 'active', score: { [1]: 80 } })
Drag options to blanks, or click blank then click option'
A$gt
B$lt
C$eq
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt which means less than.
Using $eq inside an object instead of direct value.
3fill in blank
hard

Fix the error in the query to find documents where type is 'admin' and active is true.

MongoDB
db.accounts.find({ type: [1], active: true })
Drag options to blanks, or click blank then click option'
Aadmin
B"admin"
Ctrue
D'admin'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting string values causes syntax errors.
Using boolean true as a string.
4fill in blank
hard

Fill both blanks to find documents where price is less than 100 and inStock is true.

MongoDB
db.products.find({ price: { [1]: [2] }, inStock: true })
Drag options to blanks, or click blank then click option'
A$lt
B100
Ctrue
D$gt
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt instead of $lt.
Putting true as a price value.
5fill in blank
hard

Fill all three blanks to find documents where category is 'books', rating is greater than 4, and available is false.

MongoDB
db.items.find({ category: [1], rating: { [2]: [3] }, available: false })
Drag options to blanks, or click blank then click option'
A'books'
B$gt
C4
D'bookshelf'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting 'books' string.
Using $lt instead of $gt for rating.
Putting rating value as string instead of number.