Answers for "find fields in mongodb"

Go
3

mongodb find field based on variable

var name = req.params.name;
var value = req.params.value;
var query = {};
query[name] = value;
collection.findOne(query, function (err, item) { ... });
Posted by: Guest on May-25-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

Browse Popular Code Answers by Language