Closed AntonioSpalluto closed 8 years ago
yes it is supported.
restheart uses the so called Strict mode representations of BSON, your filter uses the mongo Shell mode.
// using ISO-8601 date format following the template YYYY-MM-DDTHH:mm:ss.mmm<+/-Offset>.
?filter={"createdAt":{"$gte": {"$date": "2016-07-06T05:00:00.000"}}}
// or using unix epoch time milliseconds
?filter={"createdAt":{"$gte": {"$date": 1467792899115}}}
more info
Hi Andrea,
This doesn't apply to my question. The matter is I need to get the timestamp from the server and not calculate it on client side.
Thanks
Hi @AntonioSpalluto
for server side date, you can define an aggregation pipeline, mapReduce or simply use the $where operator:
example: $where operator with httpie:
http GET 127.0.0.1:8080/test/coll?filter='{"$where": "this.date > new Date(ISODate().getTime() - 1000*60*15)"}'
Hi Andrea,
Thanks for the hint, I will try the pipeline and the mapReduce solutions. The $where has very poor perfomance and I cannot use it.
I'll let you know the final solution.
Thanks
Hi @AntonioSpalluto
if you are familiar with java, you can also have a look at the restheart custom application logic
I think that this would be the best solution having the (current date - 15 minutes) computed server side by restheart
Hi @ujibang,
I just check it out and it looks quite simple starting from the examples: good job!
Thanks Antonio
Hi @AntonioSpalluto
closing this question now, feel free to reopen if furhter information is needed
Hi all,
I tried to use a mongodb syntax into the filter parameter to get the last created documents in the previous 15 minutes. The querystring parameter looks like this:
?filter={"createdAt":{"$gte":"new Date(ISODate().getTime()-1000*60*15)"}}
This works on mongo DB shell but not in the querystring. Is this supported by the current version?
Thanks