I tried to do it with graphLookup, but ended up with no result. Is it possible to do it with lookup only or I need to add more aggregation functions? My collection and expected result below
My collection:
[
{
"_id": "62acec38aa7bfb93f882c7d5",
"attribute_ids": [
"62acff98aa7bfb93f882c7f2",
"62acff15c51e86326c759dae"
],
"parent_id": null,
"name": "category1"
},
{
"_id": "62acec38aa7bfb93f882c7d4",
"attribute_ids": [
"62a0cfb6ba45413ec2aea923"
],
"parent_id": "62acec38aa7bfb93f882c7d5",
"name": "category2"
},
{
"_id": "62adcdbaaa7bfb93f882c7f8",
"attribute_ids": [
"62acff98aa7bfb93f882c7f2",
"62acff15c51e86326c759dae"
],
"parent_id": "62acec38aa7bfb93f882c7d4",
"name": "category2"
}
]
As a result I want to have this: