0
0
MongoDBquery~10 mins

Why performance tuning matters in MongoDB - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to find all documents in the 'users' collection.

MongoDB
db.users.[1]()
Drag options to blanks, or click blank then click option'
Afind
Binsert
Cupdate
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using insert() instead of find()
Using update() when you want to read data
2fill in blank
medium

Complete the code to find users older than 25.

MongoDB
db.users.find({ age: { [1]: 25 } })
Drag options to blanks, or click blank then click option'
A$gt
B$eq
C$ne
D$lt
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt (less than) instead of $gt
Using $eq which means equal
3fill in blank
hard

Fix the error in the query to find users with name 'Alice'.

MongoDB
db.users.find({ name: [1] })
Drag options to blanks, or click blank then click option'
A{name: 'Alice'}
BAlice
C"Alice"
D'Alice'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the string
Using an object instead of a string
4fill in blank
hard

Fill both blanks to find users with age between 20 and 30.

MongoDB
db.users.find({ age: { [1]: 20, [2]: 30 } })
Drag options to blanks, or click blank then click option'
A$gte
B$lt
C$lte
D$gt
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt and $lt which exclude 20 and 30
Mixing up the operators
5fill in blank
hard

Fill all three blanks to create an index on the 'email' field in ascending order.

MongoDB
db.users.createIndex({ [1]: [2] }, { unique: [3] })
Drag options to blanks, or click blank then click option'
Aemail
B1
Ctrue
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of 1 for ascending
Setting unique to false or 0