I have in my aggregation pipeline a subarray structure like this:
{
"_id": "london_10:2016-10-07 12",
"data": {
"voltage_a": 0.008888,
"voltage_b": 0.008888,
"voltage_c": 0.008888,
},
"Voltage (V)": 0.008888,
"datetime": "2016-10-07T11:25:46"
},
In the $project stage, I'm passing through everything in the subarray 'data' as it currently exists:
[
'$project' => [
'data' => '$data',
'Voltage (V)' => [
'$divide' => [
['$add' => ['$data.voltage_a', '$data.voltage_b', '$data.voltage_c']]
],
],
]
]
How do I project the data such that it outputs voltage_a, voltage_b and voltage_c at the same level as "Voltage (V)" and "datetime", i.e. a flat structure?