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将通过对每个要填充的文档执行单独的查询()来确保每个文档的限制正确
谢谢,我正在从零开始编程。我记得我在某种程度上看到了这个问题,但我不记得在哪里。谢谢