[英]restheart date format issue
I Have two data in the same file like 我在同一文件中有两个数据
{
"_id": {
"$oid": "57852a53"
},
"date": "2016-1-7"
},
{
"_id": {
"$oid": "57852a54"
},
"date": "2016-1-22
}
if I querying http://test:8081/xyz?filter= {'date':{'$gte':'2016-1-22'}} it showing both data 如果我查询http:// test:8081 / xyz?filter = {'date':{'$ gte':'2016-1-22'}},它会显示两个数据
I think it's not an issue but I didn't find the solution yet. 我认为这不是问题,但我尚未找到解决方案。
Thanks 谢谢
Seems like you are storing data as a string (not a proper one). 似乎您将数据存储为字符串(不是正确的字符串)。 Ideally, Suggest you to change type to Date/long.
理想情况下,建议您将类型更改为“日期/长”。
Example data: 示例数据:
{
"_id": {
"$oid": "57852a53"
},
"date": ISODate("2016-01-07T00:00:00Z")
},
{
"_id": {
"$oid": "57852a54"
},
"date": ISODate("2016-01-22T00:00:00Z")
}
If you want to persist your date a string, you can try storing in following format (note the zeros before single digit numbers) and your query should work fine. 如果要保留字符串的日期,可以尝试以以下格式存储(请注意一位数字之前的零 ),并且查询应该可以正常工作。
{
"_id": {
"$oid": "57852a53"
},
"date": "2016-01-07"
},
{
"_id": {
"$oid": "57852a54"
},
"date": "2016-01-22"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.