I have data in an aggregation pipeline stage in the following format:
[
{
"_id": "62702be5d87ed16cea3b2315",
"G": 3,
"N": [
1295748572
],
"t": "020682390"
},
{
"_id": "62702be5d87ed16cea3b2316",
"G": 3,
"N": [
1609988849
],
"t": "200766679"
},
{
"_id": "62702be5d87ed16cea3b2317",
"G": 3,
"N": [
1083965362
],
"t": "105764876"
},
{
"_id": "62702be5d87ed16cea3b2318",
"G": 3,
"N": [
1063897809,
1144556531,
1316227135
],
"t": "200719145"
}
]
I want to group on “G” and use it as an “id” field, with the rest of the data in the array.
My desired result would be:
{
"G": 3,
"N": [
1295748572
],
"t": "020682390",
"N": [
1609988849
],
"t": "200766679",
"N": [
1083965362
],
"t": "105764876",
"N": [
1063897809,
1144556531,
1316227135
],
"t": "200719145"
}
The raw data is coming from SQL Server and I have control over everything but the final output format. There are hundreds of groups (“G”) with members, and each member can have multiple “N” values and one “t” value.
Any help or directions is greatly appreciated. I am very experienced in SQL, but still learning NoSQL.