Answers for "mongodb projection example"

3

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

mongodb projection example

{ $project: { "field1": 0, "field2": 1, ... } }
Posted by: Guest on April-05-2021
4

mongodb select fields

db.inventory.find( { status: "A" }, { item: 1, status: 1 } )
Posted by: Guest on September-24-2020
0

mongodb projection example

{ $project: { "fieldN": "$fieldNewName"} }
Posted by: Guest on May-01-2021

Browse Popular Code Answers by Language