I'm very new to this and I have found that I have to use the $lookup instead of populate in my code. Since I have no experience with this I need some help with how to do it to the below code.
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
});
I want to use $lookup instead of this populate function. Please help