Projections in MongoDB

db.collection_name.find(<query>, <projections>)
db.collection_name.find(<query>, {"field1": 1, "field2": 1})
db.collection_name.find(<query>, {"field3": 0, "field4": 0})

For example, let's look at the documents in the sample_training.grades collections

Let's say we want to find out how many students took the course 431 and scored more than 85%.

db.grades.find({"class_id": 431, "scores": {"$elemMatch": {"score": {"$gt": 85}}}}).count()

Now let's find all the students who received an extra credit for any course

Lab

db.companies.find({"offices": {"$elemMatch": {"city": "Seattle"}}}).count()