Return only specific fields from matches.

Section: Projection, sort, and page

Project selected fields

javascript
javascript
db.users.find({ active: true }, { name: 1, email: 1, _id: 0 })
Explanation

Projection can reduce payload size and improve clarity.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Projection, sort, and page
Sort newest first
Sort descending on a field.
OpenIn sheetjavascriptsame section
Limit result size
Return only a fixed number of documents.
OpenIn sheetjavascriptsame section
Offset pagination
Page through results with skip and limit.
OpenIn sheetjavascriptsame section
Cursor-style pagination idea
Use a stable sort key such as `_id` or a timestamp.
OpenIn sheetjavascriptsame section
Comparison operators
Filter with range operators.
OpenIn sheetjavascript1 tag match
Match a list of values
Filter using `$in`.
OpenIn sheetjavascript1 tag match