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)}
如何对上述数据进行 Map-Reduce 或聚合以生成输出:
{"thread": "abc", "messages_per_month": 5}
{"thread": "efg", "messages_per_month": 4}
我正在尝试编写一些代码,但很难在未排序的日期上取平均值。是否有任何内置函数可以按时平均执行此操作?