mongodb find get field code example
Example 1: 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) { ... });
Example 2: mongodb select fields
db.inventory.find( { status: "A" }, { item: 1, status: 1 } )
Example 3: mongodb project all fields
db.collection.aggregate([
{ "$addFields": { "custom_field": "$obj.obj_field1" } }
])