在MongoDB中,我想制作每小时的统计数据。 为此,我将搜索时间戳在00:00到00:05,01:00和01:05之间的所有文档等。 (数据每5分钟导入一次)
以下是存储文档的示例。时间戳是UNIX时间戳(不含毫秒)
{
"_id" : ObjectId("5a6606355bfe62086d368df1"),
"timestamp" : 1511492352,
"value" : 2.0
},
{
"_id" : ObjectId("5a6606355bfe62086d368e20"),
"timestamp" : 1515556761,
"value" : 3.0
},
我当前的查询看起来像这样,但它不起作用
.find({new Date(timestamp*1000).getMinutes():{ $lt: 5 }} )
请帮我找到正确的查询
答案 0 :(得分:0)
好的,我找到了语法:
.find("new Date(this.timestamp*1000).getMinutes() < 5")