填充似乎没有填充所有数组元素

Populate does not seem to populate for all the array elements

考虑以下代码:

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"
      }
    });

这是输出:

问题:只填充了第一个 children。我有 double-checked 数据库,它不是空的

我好像看到过这个问题,但是想不起来在哪里了。 谁能帮我回忆一下?

尝试将 perDocumentLimit 添加到您的填充选项中: https://mongoosejs.com/docs/api/model.html#model_Model.populate

For legacy reasons, limit with populate() may give incorrect results because it only executes a single query for every document being populated. If you set perDocumentLimit, Mongoose will ensure correct limit per document by executing a separate query for each document to populate().