mongodb only select certain fields 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: get only some fields of document in mongodb
db.student.find({}, {roll:1, _id:0})
same as SELECT roll FROM student