Mongodb Aggregation Framework and timestamp
问题 I have a collection { "_id" : 1325376000, "value" : 13393} { "_id" : 1325462400, "value" : 13393} ObjectIds are Unix Timestamp and are storing as Number manually.(at insert time). now I'm searching for a solution that i could calculate sum of values for each month with Aggregation Framework. 回答1: Here is a way you can do it by generating the aggregation pipeline programmatically: numberOfMonths=24; /* number of months you want to go back from today's */ now=new Date(); year=now.getFullYear();