Been having trouble joining grouped data to the source data. This would be easy with relational SQL, but been spending hours trying to do this with CosmosDB SQL API with no success. Any suggestions would be greatly appreciated!
Here is the source document:
[
{
"stream":{
"id":"L1",
"version":1,
"versionName":"abc1"
}
},
{
"stream":{
"id":"L1",
"version":2,
"versionName":"abc2"
}
},
{
"stream":{
"id":"L2",
"version":1,
"versionName":"xyz1"
}
},
{
"stream":{
"id":"L2",
"version":2,
"versionName":"xyz2"
}
},
{
"stream":{
"id":"L2",
"version":3,
"versionName":"xyz3"
}
}
]
Here is the goal (grouped by id):
[
{
"id":"L1",
"versions":[
{
"version":1,
"versionName":"abc1"
},
{
"version":2,
"versionName":"abc2"
}
]
},
{
"id":"L2",
"versions":[
{
"version":1,
"versionName":"xyz1"
},
{
"version":2,
"versionName":"xyz2"
},
{
"version":3,
"versionName":"xyz3"
}
]
}
]
I wonder if this is can be done or if it can only be joined together in javascript after the query results are returned?