0
0
MongoDBquery~10 mins

Index intersection 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 age is 25 using an index.

MongoDB
db.users.find({ age: [1] })
Drag options to blanks, or click blank then click option'
A"25"
B{ $eq: 25 }
C25
D{ age: 25 }
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers causes type mismatch.
Using nested objects incorrectly in the query.
2fill in blank
medium

Complete the query to find documents where age is 25 and status is 'A' using index intersection.

MongoDB
db.users.find({ age: 25, status: [1] })
Drag options to blanks, or click blank then click option'
A{ status: "A" }
B"A"
C{ $eq: "A" }
DA
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting string values causes errors.
Using nested objects unnecessarily.
3fill in blank
hard

Fix the error in the query to use index intersection for age and status.

MongoDB
db.users.find({ age: [1], status: "A" })
Drag options to blanks, or click blank then click option'
A"25"
B{ age: 25 }
C{ $eq: 25 }
D25
Attempts:
3 left
💡 Hint
Common Mistakes
Using string '25' instead of number 25.
Using nested objects incorrectly.
4fill in blank
hard

Fill both blanks to create a query that uses index intersection for age and status.

MongoDB
db.users.find({ age: [1], status: [2] })
Drag options to blanks, or click blank then click option'
A25
B"A"
C30
D"B"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up numbers and strings.
Using wrong values for age or status.
5fill in blank
hard

Fill all three blanks to create a query that uses index intersection for age, status, and score.

MongoDB
db.users.find({ age: [1], status: [2], score: [3] })
Drag options to blanks, or click blank then click option'
A25
B"A"
C85
D"B"
Attempts:
3 left
💡 Hint
Common Mistakes
Quoting numbers or not quoting strings.
Using wrong values for fields.