I have a bunch of documents:
{"timestamp" : 1304535236, "value" : 2}
{"timestamp" : 1304532236, "value" : 5}
{"timestamp" : 1304535647, "value" : 1}
where timestamp is a unix timestamp. I would like to sum up the total number of value for each day. Note: There may be a number of documents whose timestamps fall on the same day just at different times.
If I do a normal mongo group query is sums up per timestamp because they are all unique, which is un-helpful.
You have to convert your
timestampvalues intoDateobjects so that you can group by day.Using Rachel’s answer as a starting point (in the shell):
returns: