0
0
MongoDBquery~10 mins

Mongos router 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 all documents in the 'users' collection using mongos.

MongoDB
db.users.[1]()
Drag options to blanks, or click blank then click option'
Aupdate
Bfind
Cinsert
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using insert() instead of find() to retrieve data.
Using update() or remove() which modify data, not retrieve.
2fill in blank
medium

Complete the code to insert a document into the 'orders' collection via mongos.

MongoDB
db.orders.[1]({"item": "book", "qty": 3})
Drag options to blanks, or click blank then click option'
Afind
BdeleteOne
CinsertOne
DupdateOne
Attempts:
3 left
💡 Hint
Common Mistakes
Using find() which only reads data.
Using deleteOne() or updateOne() which modify or remove data.
3fill in blank
hard

Fix the error in the query to update the quantity of an order via mongos.

MongoDB
db.orders.updateOne({"item": "book"}, {$set: [1])
Drag options to blanks, or click blank then click option'
A{"qty": 5}
B{"qty": 5
C"qty": 5}
D{qty: 5}
Attempts:
3 left
💡 Hint
Common Mistakes
Missing closing brace or quote.
Not using quotes around the key.
4fill in blank
hard

Fill both blanks to query documents where the shard key 'userId' equals 12345.

MongoDB
db.users.find([1]: [2])
Drag options to blanks, or click blank then click option'
A"userId"
B12345
C"orderId"
D67890
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong field name like 'orderId'.
Using string instead of number for the value.
5fill in blank
hard

Fill all three blanks to update the 'status' field to 'shipped' for order with orderId 67890 via mongos.

MongoDB
db.orders.updateOne([1]: [2], {$set: [3]: "shipped"}})
Drag options to blanks, or click blank then click option'
A"orderId"
B67890
C"status"
D"qty"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong field names in filter or update.
Not quoting field names properly.