Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse REST API date range query

I am trying to figure out how I can make a request to the REST API for Parse that can accept a range against the createdAt column. I can issue the following constraint which works but when I try a compound query that tries to do a GT and a LT constraint I get a Bad Request error.

var requestParams = 'where={ "createdAt": { "$gt": { "__type": "Date", "iso": "' + startDate + '" } } } ';

Is this possible with the REST API?

like image 496
Kevin Avatar asked Sep 05 '25 03:09

Kevin


1 Answers

I'm not quite sure in what format you are passing the startDate. The correct example to do such a thing is as follows.

curl
    -X GET
    -H "X-Parse-Application-Id: [APP_ID]"
    -H "X-Parse-REST-API-Key: [KEY]"
    -G --data-urlencode 'where={"createdAt":{"$gte":{ "__type": "Date", "iso": "2014-07-28T07:57:03.900Z" }}}'   
    https://api.parse.com/1/classes/[YOUR CLASS]

The example below shows how to do this using their Javascript SDK

Javascript query using greaterThan "createdAt"

like image 143
C-- Avatar answered Sep 08 '25 23:09

C--