Projection is the second argument to find() that controls which fields are returned in each result document. Rather than transferring every stored field, you shape the output to only what your application actually needs.
db.collection.find(/* filter */, /* projection */)
Two Mutually Exclusive Modes
| Mode | Syntax | Behavior |
|---|---|---|
| Inclusion | { field: 1 } |
Return ONLY the listed fields (plus _id by default) |
| Exclusion | { field: 0 } |
Return ALL fields EXCEPT the listed ones |
1) and exclusion (0) in the same projection document. The only exception is _id, which can be set to 0 alongside inclusion fields.The _id Special Case
_id is always included in results unless you explicitly set { _id: 0 }. This applies even in inclusion mode — MongoDB always returns _id unless you opt out.
Why Use Projection?
- Reduces network payload — only transmit the bytes your application needs
- Reduces memory usage — smaller working documents in your app and driver
- Enables covered queries — satisfy queries entirely via index with no document fetch
- Protects sensitive data — exclude fields like
passwordorssnat the query layer
// No projection — full document returned for every match db.users.find({ active: true }) // With projection — only name and email returned db.users.find({ active: true }, { name: 1, email: 1 })