Created
May 2, 2013 14:45
-
-
Save cschlyter/5502697 to your computer and use it in GitHub Desktop.
MongoDB: group data by day (group)
This file contains hidden or 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.link_access.group( | |
{ | |
keyf: function(doc) { | |
var date = new Date(doc.date); | |
var dateKey = (date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear()+''; | |
return {'day': dateKey}; | |
}, | |
cond: {short_id: "N"}, | |
initial: {count:0}, | |
reduce: function(obj, prev) {prev.count++;} | |
}); | |
//http://stackoverflow.com/questions/5168904/group-by-dates-in-mongodb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment