Du skal bruge $dayOfYear
objekt som værdien af et nyt felt i dit _id
, sådan her:
db.builds.aggregate(
{ $group: {
_id: {
build_result: "$build_result",
dayOfYear: { $dayOfYear: "$build_timestamp" }
},
build_duration: { $avg: "$build_duration" }
} }
)
Output:
{
"result": [
{
"_id": {
"build_result": "SUCCESS",
"dayOfYear": 15
},
"build_duration": 667075
}
],
"ok": 1
}