Start a new topic

Query Bug in Backend?

This query fails to sort the data properly:



/appdata/kid_VTn1d7yTmi/event/?query={"_geoloc":{"$nearSphere":[41.004107798550741,-79.806257851328539],"$maxDistance":100.0}}&resolve_depth=1&sort={'attendees' : -1 }&skip=0



Whereas this query does:



/appdata/kid_VTn1d7yTmi/event/?query={"_geoloc":{"$nearSphere":[41.004107798550741,-79.806257851328539],"$maxDistance":100.0}}&resolve_depth=1&sort=attendees&skip=0



As does this query:

/appdata/kid_VTn1d7yTmi/event/?resolve_depth=1&sort={'attendees' : -1 }&skip=0



Could that be a kinvey/mongodb bug or am I missing something here?



jr

Hi, the issue is that when you specify the descending sort parameter, you are using single quotes to delimit your field, which is not valid JSON. If you instead use double quotes, your query will work as expected.
Also, an ascending sort does work properly. It is only a descending sort with the geolocation query that fails.



/appdata/kid_VTn1d7yTmi/event/?query={"_geoloc":{"$nearSphere":[41.004107798550741,-79.806257851328539],"$maxDistance":100.0}}&resolve_depth=1&sort=attendees&skip=0
Login or Signup to post a comment