Is there any way that will only return the field of the store that has grade B?

I tried: {"Result.Grade" : "B"} ) But it will return back all document content with grade B.


1 Answers

Anthony Winzlet On Best Solutions

First argument in the find query is for filter. Use second argument and pass the fields you want to retrieve.
  { "Result.Grade" : "B" },   //filter
  { "Name": 1, "Number": 1 }      //projection

With the mongodb node driver use .project() cursor method
  { "Result.Grade" : "B" },
).project({ "Name": 1, "Number": 1 })