Search code examples
eve

Eve: query by date range using 'where'


Given this example curl, I'd expect to find all events that start after the given date.

events?where={"start_time": {"$gt": "2014-10-25T03:00:00Z"}}
curl -i -g 'http://127.0.0.1:5000/events?where={%22start_time%22:%20{%22$gt%22:%20%222014-10-25T03:00:00Z%22}}'

However, mongo doesn't return anything unless I intercept the request and turn it into a date object. I've defined start_date to be a datetime object in my schema.

Is this expected behavior? Is there another way to get the results I want without using a pre-request hook and validating/converting the datetime strings for certain keys?


Solution

  • Try this:

    events?where={"start_time": {"$gt": "Fri, 10 Oct 2014 03:00:00 GMT"}}
    

    You are supposed to pass RFC1123 dates with your queries and/or JSON fields.