I am running this code on node.js
var mongoose = require('mongoose');
mongoose.model('participant',new mongoose.Schema({},{ collection : 'forumParticipant' }));
var Participant = mongoose.model('participant');
mongoose.connect('******');
Participant.find({entity_id: 0}, function (err, docs) {
console.log(docs[0]);
console.log(docs[0].entity_id)
});
1) The first console.log returns the full document
2) The second .log console returns undefinied
I do not understand why.
I need to do something like
var participants = docs.map(function(d){return d.user_id})
How can i achieve this? What am I missing?
source
share