I want to take a dataset which is an object where the the value field has an array value. I want to iterate through the array and group them by the different ids. I also want it to get an aggregate of "count"(total count) and have a field for the different type of "status" and its associated count.
"value": [
{
"count": 5,
"id": "id1",
"status": 1
},
{
"count": 2,
"id": "id1",
"status": 3
},
{
"count": 2,
"id": "id1",
"status": 4
},
{
"count": 1,
"id": "id2",
"status": 0
},
{
"count": 2,
"id": "id2",
"status": 1
},
{
"count": 7,
"id": "id2",
"status": 2
},
{
"count": 5,
"id": "id2",
"status": 3
},
{
"count": 3,
"id": "id2",
"status": 4
}
]
}```
desired output is a map where the keys are ids and value is made up of totalCount(aggregate of all the counts of that id), statusx(where x is the different type of status. There will be a limited type of status. Maybe 5 or so) that has the count of that status, and "status" to show what type of status it is(0-5):
{
id1 : { totalCount: 9, status1 : 5, status3: 2, status4:2},
id2 : { totalCount: 18, status0 : 1, status1 : 2, status2: 7, status3: 5, status4:3}
}