I need some help figuring out how to make a custom query. Here is the scenario:
In my User
's table there is a property radius
which is specified by each user. There’s also another for the user’s lastLocation
. When a new GeoPoint is added I want to get all users for which the new GeoPoint is within radius
of their lastLocation
.
Can this be achieved with a single query (probably with a subquery) instead of getting all users and looping through them on the device (which could have a huge overhead)?
Hi Milen,
Try to use business logic and create Event Handler.
Select section Business Logic in developer console -> EVENT HANDLERS -> New Event Handler ->
Language: Java, JS or CODELESS
Model: Default
Category: Geolocation
Event: addPoint
Timing: before or after
Context: All Geo Categories or what you need
-> SAVE
Download this handler and to get all users for which the new GeoPoint is within radius of their lastLocation.
See more about Event Handlere - https://backendless.com/products/documentation/ section ‘Custom Business Logic - Java’ or ‘Custom Business Logic - JS’
Hi Vladimir,
Thanks for the reply! Whether this happens in an event handler on the server or on device, my problem is indeed forming the query for:
get all users for which the new GeoPoint is within radius of their lastLocation
Get all Users from User
s table where (lastLocation + radius) included NewGeoPoint
See about search with radius https://backendless.com/docs/android/geo_radius_based_search.html - Search in categories with radius