Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.getCollection('consos').aggregate([
- {
- "$project": {
- "yearMonthDay": { "$dateToString": { "format": "%Y-%m-%d", "date": "$date" } },
- "time": { "$dateToString": { "format": "%H:%M:%S:%L", "date": "$date" } },
- "weekday": "$weekday"
- }
- },
- {
- "$group" : {
- "_id" : {
- "date" : "$yearMonthDay",
- "weekday" : "$weekday"
- },
- "count" : { "$sum" : 1 },
- }
- },
- // sort from most recent to oldest
- {
- "$sort": { "_id.date": -1 }
- },
- // select first ten results
- {
- "$limit": 10
- },
- // reverse order of ten results
- {
- "$sort": { "_id.date": 1 }
- },
- {
- "$project" : {
- "_id" : 0,
- "date" : "$_id.date",
- "weekday" : "$_id.weekday",
- "count" : 1
- }
- }
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement