Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 2级以上的猫鼬种群_Node.js_Mongodb_Mongoose - Fatal编程技术网

Node.js 2级以上的猫鼬种群

Node.js 2级以上的猫鼬种群,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我尝试使用mongoose填充来返回一个复合文档。类别和问题扩展得很好。问题中的答案数组未展开。这就是我一直在做的 summarySchema.statics.loadFull = function(options, callback){ var self = this; self.findOne(options).populate([{ path: 'categories' }]) .exec(function(err, res){

我尝试使用mongoose填充来返回一个复合文档。类别和问题扩展得很好。问题中的答案数组未展开。这就是我一直在做的

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);
            });
        });
    });
};
我是否犯了一个明显的错误,或者猫鼬不支持超过2个级别的种群

仅供参考,结构如下

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'}]}

我犯了一个愚蠢的错误,除非您看到返回的数据,否则可能不会很明显。我不应该检查不是数组或字符串的对象的长度。我把返回值弄糊涂了