Answers for "mongodb get only specific 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
1

find only one field mongodb

db.students.find({}, {roll:1, _id:0})
Posted by: Guest on March-19-2021

Code answers related to "mongodb get only specific fields"

Browse Popular Code Answers by Language