0
0
MongoDBquery~10 mins

Pretty printing and cursor 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 pretty print all documents from the 'users' collection.

MongoDB
db.users.find().[1]()
Drag options to blanks, or click blank then click option'
Apretty
BtoArray
Ccount
Dlimit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'toArray()' instead of 'pretty()' which returns an array but does not format output.
Using 'count()' which returns the number of documents, not the documents themselves.
2fill in blank
medium

Complete the code to get the first 5 documents from the 'orders' collection.

MongoDB
db.orders.find().[1](5)
Drag options to blanks, or click blank then click option'
Askip
Bpretty
Climit
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'skip()' which skips documents but does not limit the number returned.
Using 'count()' which returns the number of documents, not the documents themselves.
3fill in blank
hard

Fix the error in the code to convert the cursor to an array.

MongoDB
const docs = db.products.find().[1]()
Drag options to blanks, or click blank then click option'
AtoArray
Bpretty
Ccount
Dlimit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pretty()' which formats output but does not convert to array.
Using 'count()' which returns the number of documents.
4fill in blank
hard

Fill both blanks to skip the first 3 documents and limit the result to 4 documents.

MongoDB
db.sales.find().[1](3).[2](4)
Drag options to blanks, or click blank then click option'
Askip
Blimit
Cpretty
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the order of 'skip' and 'limit' which changes the result.
Using 'pretty' or 'count' which do not control skipping or limiting.
5fill in blank
hard

Fill all three blanks to pretty print documents from 'inventory', skip 2, and limit to 3.

MongoDB
db.inventory.find().[1]().[2](2).[3](3)
Drag options to blanks, or click blank then click option'
Apretty
Bskip
Climit
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count()' which does not affect output formatting or cursor behavior.
Changing the order of methods which affects the result.