Back to MongoDB Notes
Topic #15

$project


Aggregation $project

This aggregation stage passes only the specified fields along to the next aggregation stage.

Note: This is the same projection that is used with the find() method.

Example

db.restaurants.aggregate([
  {
    $project: {
      "name": 1,
      "cuisine": 1,
      "address": 1
    }
  },
  {
    $limit: 5
  }
])

This will return the documents but only include the specified fields.

Note: Notice that the _id field is also included. This field is always included unless specifically excluded.

We use a 1 to include a field and 0 to exclude a field.

Note: You cannot use both 0 and 1 in the same object. The only exception is the _id field. You should either specify the fields you would like to include or the fields you would like to exclude.

Want to go beyond the notes?

Join Coding Now Tech Institute's MongoDB course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

$project – FAQs

Quick answers about learning $project in MongoDB.

This free note from Coding Now Tech Institute explains $project in MongoDB — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every MongoDB topic on Coding Now Tech Institute, including $project, is 100% free with no signup required.
With focused practice, most students grasp $project in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now