我的文件格式为:
{
"_id": 1517209200000,
"timestamp": 1517209200000,
"current": 236078,
}
时间戳是日期的纪元表示,每天插入约100个文档。它存储为数字。
我试图找出如何打印过去30天的平均$current
以及每天的最小值和最大值。
我找到了$ dayOfYear聚合但是我不知道如何将它应用到我的纪元时间戳。 (https://docs.mongodb.com/manual/reference/operator/aggregation/dayOfYear/)
如果他们知道答案,有人可以分享他们的知识吗?
谢谢
编辑:我的第一次尝试返回错误:"errmsg" : "can't convert from BSON type double to Date",
db.cable23.aggregate([ { $match: {'direction': 0} },{$group : {'_id': {'$year': "$timestamp"}}}])