mongodb - How to populate fields after mapReduce with Mongoose.js? -
i want populate fields after mapreduce.
mongoose.connection.db.collection('createdcollectionnameforresults', function(err, collection) { collection.find({}).populate('ref_field').toarray(function(err, items) { res.send(200, items) }); });
but here, gives error:
typeerror: object # has no method 'populate'
because collection.find({}) returns mongodb cursor. how can populate ref_field?
considering have schema registered in mongoose named 'createdcollectionnameforresults'
var model = mongoose.model('createdcollectionnameforresults'); model.find({}).populate('ref_field').exec(function(err, results){ console.log(err, results); });
mongodb mapreduce mongoose
No comments:
Post a Comment