Answers for "mongodb select only fields"

Go
4

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
Posted by: Guest on December-07-2020
0

get only some fields of document in mongodb

db.student.find({}, {roll:1, _id:0})
 same as SELECT roll FROM student
Posted by: Guest on May-18-2021

Code answers related to "mongodb select only fields"

Browse Popular Code Answers by Language