Answers for "mongoose find only one field"

Go
5

mongoose find return only certain fields

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

findbyid mongoose

// Find the adventure with the given `id`, or `null` if not found
await Adventure.findById(id).exec();

// using callback
Adventure.findById(id, function (err, adventure) {});

// select only the adventures name and length
await Adventure.findById(id, 'name length').exec();
Posted by: Guest on September-24-2020

Code answers related to "mongoose find only one field"

Browse Popular Code Answers by Language