Last active
April 19, 2016 16:14
-
-
Save rjurado01/295dd457e3c7736d45a86b50e688bf53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Spot | |
field :location, type: Array | |
index({ location: '2d' }, { min: -180, max: 180 }) | |
end | |
Spot.create_indexes | |
Spot.create(location: [1,0]) | |
Spot.create(location: [3,0]) | |
Spot.where(location: {"$near" => {lng: 0, lat: 0}, "$maxDistance" => 2}).all.map(&:location) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment