Given the following documents:
/* 1 */
{
"_id" : ObjectId("5f38fb2b52e28012a8f175f9"),
"date" : "2020-08-16",
"values" : {
"wert1" : 5.0,
"wert2" : 9.0
}
}
/* 2 */
{
"_id" : ObjectId("5f38fb2b52e28012a8f175fa"),
"date" : "2020-08-16",
"values" : {
"wert1" : 3.0,
"wert3" : 10.0
}
}
How can I transform this into something like the following:
{ "wert1": [ { "2020-08-16": "8.0" } ] },
{ "wert2": [ { "2020-08-16": "9.0" } ] },
{ "wert3": [ { "2020-08-16": "10.0" } ] }
In theory in would be a:
- "SelectMany"
$values.$key - Group by
$keyand$datewith$sumof values - Transform
What is the operator for this "SelectMany"?