I derived the following data using the aggregate of mongodb.
{
"first_count": 2,
"second_count": 1,
"third_count": 2,
"test_count": 2,
"sido": "대구",
"guguns": [
{
"gugun": "남시",
"first_count": 1,
"second_count": 1,
"third_count": 1
},
{
"gugun": "부천군",
"first_count": 1,
"second_count": 0,
"third_count": 1
},
{
"gugun": "남시",
"test_count": 1
},
{
"gugun": "부천군",
"test_count": 1
}
]
}
This is the result of merging two facet data. But the result I want is:
{
"first_count": 2,
"second_count": 1,
"third_count": 2,
"test_count": 2,
"sido": "대구",
"guguns": [
{
"gugun": "남시",
"first_count": 1,
"second_count": 1,
"third_count": 1,
"test_count": 1
},
{
"gugun": "부천군",
"first_count": 1,
"second_count": 0,
"third_count": 1,
"test_count": 1
}
]
}
How does guguns.gugun combine the same values into one?
If possible, I would like to process it using mongodb aggregate.