Apply for Zend Framework Certification Training


By default ,
if we perform any query on a mongodb collection it tends to return all the data
of a field in the matching document. So in order to avoid that we use projection.
Projections limit the fields returned by the query. The projection document can
specify the inclusion as well as exclusion of the fields as shows
below: { field-name-1 : value , field-name-2 : value, ..,.., so on}
here value can be either 1 or 0 where 1 signifies inclusion and 0 signifies exclusion.

        .find({ position : "manager"})    
		.project({name:1 , email: 1})
        .toArray( (err , collection) => {
		 if(err) throw err;
		   console.log("Record foundsuccessfully");

< groupBy and condition in mongodb Uses of updateOne and updateMany in mongoDb >

Ask a question

  • Question:
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question

Back to Top