I have a user's collection with Latitude and longitude points for each user.
I want to calculate distance between given Lat, long values and user's location.
In MYSQL there is a query for it
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
Is there any equivalent approach/ Query in mongodb? There are ways to accomplish this in Javascript but it would be better if coded in a Query.