These are chat archives for Automattic/mongoose

Sep 2015
Erinç Fırtına
Sep 03 2015 10:23
This message was deleted
Erinç Fırtına
Sep 03 2015 10:50

I have a little complicated model I am trying to populate some field in one query but it is failing. Problem is I have same type field more than once in a document and also in subdocuments. when I try a query like this:

Model.findOne({_id: id}).populate(’subdoc1’).populate(‘subdoc2’).exec(function(err, doc){
if(err){ return false;}
doc.populate(‘field1’).populate(‘field2’).populate(’subdoc1.field1’).populate(’subdoc1.field2’).populate(’subdoc2.field1’).populate(’subdoc2.field2’, function(err,  fullDoc){
if(err){return false;}


subdoc1 and subdoc2 are array of ObjectId and different model. after this mongoose populate field1 and field2 on parent doc but does not populate on subdocs. What am I doing wrong?