Good day! I am studying mongodb and I find it difficult to group a child array. I want to group the parameters with same id.
Is it possible in mongodb to group array of child?
Initial array of objects.
"attributes": [
{
"_id": "5f3553c483477525987a6852",
"parameters": {
"_id": "5f3553c483477525987a6853",
"parameter": {
"_id": "5f35539e83477525987a684e",
"parameter": "HOMEROOM"
},
"percentage_allocation": 20
}
},
{
"_id": "5f3553c483477525987a6852",
"parameters": {
"_id": "5f35578d786afe026451470c",
"parameter": {
"_id": "5f3553a783477525987a684f",
"parameter": "PERFORMANCE"
},
"percentage_allocation": 20
}
}
]
Desired Results:
"attributes": [
{
"_id": "5f3553c483477525987a6852",
"parameters": [{
"_id": "5f3553c483477525987a6853",
"parameter": {
"_id": "5f35539e83477525987a684e",
"parameter": "HOMEROOM"
},
"percentage_allocation": 20
},
{
"_id": "5f3553a783477525987a684f",
"parameter": "PERFORMANCE"
},
"percentage_allocation": 20
}]
}
]