{
$lookup: {
from: "site",
"let": {
"pid": "$data"
},
"pipeline": [
{
"$match": {
"$expr": {
"$in": [
"$doc_id",
"$$pid"
]
}
}
}
],
"as": "subComment"
}
},
https://mongoplayground.net/p/6t2uVwLzW0A
How to make a $lookup inside array using mongodb I did try but didn't get success countRecord should be inside data whose object_id does match.
output should be
[
{
"_id": ObjectId("5ebb74ef92033b3dc79aca13"),
"content": "Here is new content",
"data": [
{
"_id": ObjectId("5e7cd2019b1c522b15cca6fe"),
"height": 1000,
"url": "xyz.jpg",
"width": 1000,
"countRecord": 2,
},
{
"_id": ObjectId("5e7cd2019b1c522b15cca6fd"),
"height": 1000,
"url": "verr.jpg",
"width": 601
}
],
"subComment": [],
"timestamp": 1.58934347177e+12,
"type": "post"
}
]