node.js - More than 2 levels of population with mongoose -


i trying use mongoose populate ability return 1 composite document. categories , questions expanded fine. answers array in questions not expanded. here's have been doing

summaryschema.statics.loadfull = function(options, callback){     var self = this;     self.findone(options).populate([{         path: 'categories'     }])     .exec(function(err, res){         if(err || !res) return callback(err, res);         self.populate(res, [{             path: 'categories.questions',             model: 'question'         }], function(err, res){             if(err || !res || !res.length) return callback(err, res);             self.populate(res, [{                 path : 'categories.questions.answers',                 model: 'answer'             }], function(err, res){                 callback(err, res);             });         });     }); }; 

is there obvious mistake making or mongoose not support more 2 levels of population.

fyi, structure

summary {categories : [{type: mongoose.schema.types.objectid, ref: 'category'}]} category {questions : [{type: mongoose.schema.types.objectid, ref: 'question'}]} question {answers : [{type: mongoose.schema.types.objectid, ref: 'answer'}]} 

i making silly mistake might not obvious unless see returned data. should not checking length on object that's not array or string. got return values confused. :)


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -