2
的MongoDB數據庫:地圖時間戳減少
{"thread": "abc", "message": "hjhjh", "Date": (2010,4,5,0,0,0)}
{"thread": "abc", "message": "hjhjh", "Date": (2009,3,5,0,0,0)}
{"thread": "efg", "message": "hjhjh", "Date": (2010,3,7,0,0,0)}
{"thread": "efg", "message": "hjhjh", "Date": (2011,4,5,0,0,0)}
我怎麼能映射簡化或聚合上述數據來生成輸出:
{"thread": "abc", "messages_per_month": 5}
{"thread": "efg", "messages_per_month": 4}
我嘗試寫一些代碼,但在未排序的日期很難平均。是否有任何內置的函數可以平均按時完成?
謝謝!最大值,最小值使它變得容易。 – codious 2012-04-11 08:55:59