What is incorrect about the projection document {_id:0, name:1, age:0}?

Prepare for the MongoDB Associate Developer Exam with flashcards and practice multiple choice questions. Each question includes hints and explanations to ensure you're ready for test day.

The projection document is indeed incorrect primarily because it mixes inclusion and exclusion, which is against the MongoDB projection rules. In MongoDB, when specifying fields for projection, you can either include specific fields or exclude them, but you cannot do both in the same projection statement.

In this particular document, _id: 0 is an exclusion of the _id field, while name: 1 is an inclusion of the name field, and age: 0 attempts to exclude the age field. This mixing of the inclusion and exclusion styles in the same projection leads to ambiguity in the result set and is not permitted.

Other options do not apply here, as the _id field is being correctly excluded, no fields are required by default, and the document does not pertain to a specific collection in this context—the issue is solely with the combination of inclusion and exclusion in the projection.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy