【发布时间】:2020-06-18 01:48:40
【问题描述】:
我对此很陌生,我发现我必须使用 $lookup 而不是填充我的代码。由于我没有这方面的经验,我需要一些帮助来了解如何对下面的代码进行操作。
postSchemaModel.aggregate([{
"$geoNear": {
"near": { "type": "Point", "coordinates": [6.7336665, 79.8994071], "Typology": "post" },
"distanceField": "dist.calculated",
"maxDistance": 5000,
"includeLocs": "dist.location",
"spherical": true
}
},
{ "limit": limit },
{ "skip": startIndex },
{ "$sort": { "createdAt": -1 } },
{ "populate": user_id },
{ "populate": "'user_id', 'img user_name _id'" }
]).then(async function(posts) {
//some code here
});
我想使用 $lookup 而不是这个填充函数。请帮忙
【问题讨论】:
-
这能回答你的问题吗? Unrecognized pipeline stage name: '$populate' 这个问题已经有同一个用户在这里提出的答案,请尝试 - 提出关于错误的任何问题并且不要重复问题..
标签: node.js mongodb mongoose mongodb-query