Guest User

Untitled

a guest
Aug 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. Maximum distance with Mongoid's Model.near method
  2. Place.near(:coordinates => location.reverse)
  3. # must reverse the resulting coordinates array because mongo stores them backwards [lng,lat]
  4.  
  5. db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } )
  6.  
  7. Place.where(:coordinates => {"$near" => location.reverse , '$maxDistance' => 20.fdiv(69)})
Add Comment
Please, Sign In to add comment