how to return only certain fields from mongodb find code example
Example 1: mongodb select specific fields
db.student.find({}, 'roll _id'); // <--- Just multiple fields name space separated
// OR
db.student.find({}).select('roll _id'); // <--- Just multiple fields name space separated
// OR
db.student.find({}, {'roll' : 1 , '_id' : 1 ); // <---- Old lengthy boring way
Example 2: find only one field mongodb
db.students.find({}, {roll:1, _id:0})
Example 3: return only specific fields mongodb
db.inventory.find( { status: "A" }, { item: 1, status: 1 } )