Anda perlu menggunakan $dayOfYear
objek sebagai nilai bidang baru di _id
. Anda , seperti ini:
db.builds.aggregate(
{ $group: {
_id: {
build_result: "$build_result",
dayOfYear: { $dayOfYear: "$build_timestamp" }
},
build_duration: { $avg: "$build_duration" }
} }
)
Keluaran:
{
"result": [
{
"_id": {
"build_result": "SUCCESS",
"dayOfYear": 15
},
"build_duration": 667075
}
],
"ok": 1
}