How to get value of array based on id from same collection in mongodb
. Here "linkedBy" is array of
"storyId". So in result in "linkedBy" array instead of only "storyId" need to fetch all details of that "storyId".
collection 1:-
{
"_id" : ObjectId("6130f4f16dc8c60fa554c37e"),
"storyId" : "101",
"storyTitle" : "story 1",
"storyPriority" : "",
"storyPoints" : "0",
"linkedBy" : [],
},
{
"_id" : ObjectId("2345f4f16dc8c60fa554c37e"),
"storyId" : "102",
"storyTitle" : "story 2",
"storyPriority" : "",
"storyPoints" : "0",
"linkedBy" : [101],
}
expected result :-
{
"_id" : ObjectId("6130f4f16dc8c60fa554c37e"),
"storyId" : "101",
"storyTitle" : "story 1",
"storyPriority" : "",
"storyPoints" : "0",
"linkedBy" : [],
},
{
"_id" : ObjectId("2345f4f16dc8c60fa554c37e"),
"storyId" : "102",
"storyTitle" : "story 2",
"storyPriority" : "",
"storyPoints" : "0",
"linkedBy" : [
{
"_id" : ObjectId("6130f4f16dc8c60fa554c37e"),
"storyId" : "101",
"storyTitle" : "story 1",
"storyPriority" : "",
"storyPoints" : "0",
"linkedBy" : [],
}
],
}