Reputation: 1
let somevar = candidate.find({}, {_id:0,name:1 });
console.log(somevar.map());
Current output which was not expected
Query {
...
collectionName: 'candidates'
},
_traceFunction: undefined,
'$useProjection': true,
_userProvidedFields: { _id: 0, name: 1 }
}
Im not able to understand the error, so want someone to explain me whats happening here. What i expected it to do is
["name1","name2".....]
Upvotes: 0
Views: 25
Reputation: 2494
You are creating a query but not executing it. You need to either do:
let someVar = await candidate.find()
Or
candidate.find().exec(function(err, candidates){
console.log(candidates)
});
Upvotes: 2