Sorting by nearest locations in Backand?

145 Views Asked by At

Is it possible to sort returned objects from Backand based on how near the location field of type "point" is to the querying users current location?

From the Backand docs I have only seen support for querying based on a maximum distance from a point but nothing about sorting by geo points.

1

There are 1 best solutions below

1
Jack Collins On

I was able to create a custom query in Backand which I can hit from the Backand API. Unfortunately in order to sort on the distance of nearby users I need to calculate the distance from the current user to every other user in the database and then sort based on this. Seems very complex - a lot of calculations every time the query is called! Will probably see big performance hits as the database gets larger. Guess it answers this question, but I am hopeful still of finding a better alternative.