I'm using Mongo DB and I have a list of object that I need to group in category -> subcategory -> different types of subcategory grouped together. You can find the code in this mongodb playground > https://mongoplayground.net/p/BfR7FT28XKN
I create the group category -> all the sub category. But how can I group the subcategory with the same name?
My goal is to achieve something like that:
{
"_id": "Food and Drink",
"subCategories": [
{
"details": "Wine Bar",
"subCategory": "Bar",
},
{
"details": "Jazz and Blues Cafe",
"subCategory": "Nightlife",
},
{
"subCategory": "Restaurants",
"types": [
{
"details": "Mediterranean",
"subCategory": "Restaurants",
},
{
"details": "Mexican",
"subCategory": "Restaurants",
}
]
},
]
}
Thanks