0
0
MongoDBquery~10 mins

Collections vs tables mental model in MongoDB - Interactive Practice

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 collection.

MongoDB
db.users.[1]()
Drag options to blanks, or click blank then click option'
Afind
Bdelete
Cupdate
Dinsert
Attempts:
3 left
💡 Hint
Common Mistakes
Using insert() instead of find() to get data.
Trying to update or delete when just reading.
2fill in blank
medium

Complete the code to insert a new document into the collection.

MongoDB
db.products.[1]({ name: 'Pen', price: 1.5 })
Drag options to blanks, or click blank then click option'
Afind
BdeleteOne
CupdateOne
DinsertOne
Attempts:
3 left
💡 Hint
Common Mistakes
Using find() instead of insertOne() to add data.
Using deleteOne() or updateOne() by mistake.
3fill in blank
hard

Fix the error in the code to update a document's price.

MongoDB
db.items.updateOne({ name: 'Book' }, { [1]: { price: 12 } })
Drag options to blanks, or click blank then click option'
A$add
B$get
C$set
D$remove
Attempts:
3 left
💡 Hint
Common Mistakes
Using $get or $add instead of $set.
Forgetting the dollar sign in the operator.
4fill in blank
hard

Fill both blanks to delete all documents where age is less than 18.

MongoDB
db.students.deleteMany({ age: { [1]: [2] } })
Drag options to blanks, or click blank then click option'
A$lt
B$gt
C18
D21
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt (greater than) instead of $lt.
Using wrong age number.
5fill in blank
hard

Fill all three blanks to find documents where status is 'active' and sort by score descending.

MongoDB
db.players.find({ status: [1] }).sort({ [2]: [3] })
Drag options to blanks, or click blank then click option'
A'active'
Bscore
C-1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around 'active'.
Using 1 instead of -1 for descending sort.