0
0
MongoDBquery~10 mins

Projection for reducing data transfer 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 project only the 'name' field from the 'users' collection.

MongoDB
db.users.find({}, { [1]: 1 })
Drag options to blanks, or click blank then click option'
Aaddress
Bname
Cemail
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of 1 to include fields
Forgetting to specify the field name in the projection
2fill in blank
medium

Complete the code to exclude the '_id' field from the results.

MongoDB
db.products.find({}, { [1]: 0 })
Drag options to blanks, or click blank then click option'
Aname
Bprice
C_id
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to exclude fields by setting them to 1
Not excluding '_id' when only other fields are projected
3fill in blank
hard

Fix the error in the projection to include only 'title' and 'author' fields.

MongoDB
db.books.find({}, { title: 1, [1]: 1, _id: 0 })
Drag options to blanks, or click blank then click option'
Agenre
Bpublisher
Cyear
Dauthor
Attempts:
3 left
💡 Hint
Common Mistakes
Including fields not requested
Forgetting to exclude '_id' if not needed
4fill in blank
hard

Fill both blanks to project 'username' and exclude '_id' in the query.

MongoDB
db.accounts.find({}, { [1]: 1, [2]: 0 })
Drag options to blanks, or click blank then click option'
Ausername
Bemail
C_id
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up inclusion and exclusion values
Trying to include and exclude fields at the same time incorrectly
5fill in blank
hard

Fill all three blanks to project 'firstName', 'lastName', and exclude '_id' in the query.

MongoDB
db.employees.find({}, { [1]: 1, [2]: 1, [3]: 0 })
Drag options to blanks, or click blank then click option'
AfirstName
BlastName
C_id
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Including '_id' by mistake
Using wrong field names in projection