Files
trunk-server/mongo/totals.js
Luke Berndt 3b0d3f290f First Commit
2020-06-09 22:11:11 -04:00

29 lines
556 B
JavaScript

db = db.getMongo().getDB( "scanner" );
var results = db.calls.aggregate(
[ {
$project: {
len: true,
year: {$year: "$time"},
month: {$month: "$time"},
dayOfMonth: {$dayOfMonth: "$time"}
}
},
{
$group:
{
_id: {
year: '$year',
month: '$month',
dayOfMonth: '$dayOfMonth'
},
totalAudio: { $sum: "$len" },
count: { $sum: 1 }
}
}
]
)
results.forEach(function(document) {
printjson(document);
});