Mitt förslag skulle vara detta:
db.collection.aggregate([
{
$addFields: {
duration: {
$toLong: {
$dateFromParts: {
year: 1970,
hour: { $toInt: { $first: { $split: ["$durationHrs", ":"] } } },
minute: { $toInt: { $last: { $split: ["$durationHrs", ":"] } } },
}
}
}
}
},
{ $group: { _id: null, durations: { $sum: "$duration" } } },
{
$set: {
h: {
$toInt: {
$sum: [{
$multiply: [
{ $dayOfYear: { $toDate: "$durations" } }, 24]
},
-24,
{ $hour: { $toDate: "$durations" } }]
}
},
m: { $minute: { $toDate: "$durations" } }
}
},
{ $project: { durations: { $concat: [{ $toString: "$h" }, ":", { $toString: "$m" }] } } }
])
Tänk på att det bara fungerar i upp till ett år, dvs. 366 dagar.