Last active
January 28, 2019 17:05
-
-
Save Visrozar/5a5fd746b526eba67b22a8822c4f11ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.collection.aggregate([ | |
{ | |
"$project": { | |
"_id": 1, | |
"product": 1, | |
"time": { | |
"$dateToString": { | |
"format": "%Y-%m-%d", | |
"date": "$time" | |
} | |
} | |
}, | |
}, | |
{ | |
"$group": { | |
"_id": { | |
"time": "$time", | |
"product": "$product" | |
} | |
} | |
}, | |
{ | |
"$group": { | |
"_id": "$_id.time", | |
"count": { | |
"$sum": 1 | |
} | |
} | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment