Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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
Mongoose “填充”似乎并不是为所有数组元素填充_Mongoose_Mongoose Populate - Fatal编程技术网

Mongoose “填充”似乎并不是为所有数组元素填充

Mongoose “填充”似乎并不是为所有数组元素填充,mongoose,mongoose-populate,Mongoose,Mongoose Populate,考虑以下代码: const aux = await Fasta.find({}, "healthyTissue") .limit(1) .populate({ //---------------------first level (healthy or tumor fasta file) ---------------- path: "healthyTissue", model: "Hidden", options: {

考虑以下代码:

const aux = await Fasta.find({}, "healthyTissue")
    .limit(1)
    .populate({
      //---------------------first level (healthy or tumor fasta file) ----------------
      path: "healthyTissue",
      model: "Hidden",

      options: {
        limit: 2
      },

      //---------------------    second level (hidden documents)       ----------------
      populate: {
        path: "children",
        options: {
          limit: 2
        },
        model: "FastaElement"
      }
    });
这是输出:

问题是:只填充第一个孩子。我仔细检查了数据库,它不是空的


我觉得我已经看到了这个问题,但我不记得在哪里。有人可以刷新我的记忆吗?

尝试将
perDocumentLimit
添加到您的填充选项中:

出于传统原因,limit with populate()可能会给出不正确的结果,因为它只对每个正在填充的文档执行一个查询。如果设置perDocumentLimit,Mongoose将通过对每个要填充的文档执行单独的查询()来确保每个文档的限制正确


谢谢,我正在从零开始编程。我记得我在某种程度上看到了这个问题,但我不记得在哪里。谢谢