$reduce to iterate loop of data array
$objectToArray convert sv object to key-value array
$map to iterate loop of sv array
$objectToArray convert minute object to key-value array
$map to iterate loop of minutes array
$concat to concat the required format of date parts
$arrayToObject convert key-value pair to object
$concatArrays to concat data elements
$reduce to iterate loop of data array
$reduce to iterate loop of nested data elements
$mergeObjects to merge date objects
db.collection.aggregate([
{
$project: {
data: {
$reduce: {
input: "$data",
initialValue: [],
in: {
$concatArrays: [
"$$value",
{
$map: {
input: { $objectToArray: "$$this.sv" },
as: "s",
in: {
$map: {
input: { $objectToArray: "$$s.v" },
as: "s1",
in: {
$arrayToObject: [
[
{
k: {
$concat: ["$$this.time", ":", "$$s.k", ":", "$$s1.k", "Z"]
},
v: "$$s1.v"
}
]
]
}
}
}
}
}
]
}
}
}
}
},
{
$project: {
data: {
$reduce: {
input: "$data",
initialValue: {},
in: {
$mergeObjects: [
"$$value",
{
$reduce: {
input: "$$this",
initialValue: {},
in: { $mergeObjects: ["$$value", "$$this"] }
}
}
]
}
}
}
}
}
])
Playground