I'm working on a project using mongodb, and within an array I am currently getting two arrays with the same _id. I would like these two sets of data to be combined. What I am currently am getting:
"items": [
{
"_id": "Red",
"15-17": 1
},
{
"_id": "Bliss",
"15-17": 2
},
{
"_id": "Green",
"18-25": 1
},
{
"_id": "Bliss",
"18-25": 2
}
]
What I would like to get:
"items": [
{
"_id": "Red",
"15-17": 1
},
{
"_id": "Bliss",
"15-17": 2,
"18-25": 2
},
{
"_id": "Green",
"18-25": 1
},
]
I would really appreciate any help or advice on how to do this.