Mongodb:查询两个日期之间的文档(采用字符串格式“ 20-05-2019”)

时间:2019-05-29 11:47:40

标签: mongodb

我想从我的角度应用程序中查询mongodb中的文档,该应用程序在特定日期范围内,例如“ 26-05-2019”和“ 01-06-2019”之间。以下是一些示例文档:

文档1:

{
"timestamp" : "1558341279777",
"date" : "25-05-2019",
"hour" : "14",
"month" : "5",
"time" : "14:4:39",
"weekDay" : "Monday"
 }  

文档2:

{"timestamp" : "1558426047794",
"date" : "26-06-2019",
"hour" : "13",
"month" : "5",
"time" : "13:37:27",
"weekDay" : "Tuesday"
 }  

文档3:

{"timestamp" : "1558426047794",
"date" : "28-06-2019",
"hour" : "13",
"month" : "5",
"time" : "13:37:27",
"weekDay" : "Tuesday"
 }  

文档4:

{"timestamp" : "1558426047794",
"date" : "02-06-2019",
"hour" : "13",
"month" : "5",
"time" : "13:37:27",
"weekDay" : "Tuesday"
 }  

要求:获取日期范围为26-05-2019到01-06-2019的所有文档

预期结果:

{"timestamp" : "1558426047794",
"date" : "26-06-2019",
"hour" : "13",
"month" : "5",
"time" : "13:37:27",
"weekDay" : "Tuesday"
 },     
{"timestamp" : "1558426047794",
"date" : "28-06-2019",
 "hour" : "13",
 "month" : "5",
 "time" : "13:37:27",
 "weekDay" : "Tuesday"
 } 

我该怎么做?

0 个答案:

没有答案