i am working on a geolocation based app allowing user to retrieve adverts nearby his location.
i have developped a version with symfony2/mysql but now i would like to migrate the project to sails but i can't figure out how to do the equivalent of this sql query with sails/waterline:
SELECT
*
,((ACOS(SIN(@orig_lat * PI() / 180) * SIN(`lat` * PI() / 180) + COS(@orig_lat * PI() / 180) * COS(`lat` * PI() / 180) * COS((@orig_long - `long`) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS `distance`
FROM `cities`
WHERE
(
`lat` BETWEEN (@orig_lat - @bounding_distance) AND (@orig_lat + @bounding_distance)
AND `long` BETWEEN (@orig_long - @bounding_distance) AND (@orig_long + @bounding_distance)
)
ORDER BY `distance` ASC
limit 25;
is it even possible to do so with sails/waterline ? (i am using mongodb as driver)