Skip to content

Instantly share code, notes, and snippets.

@rjurado01
Last active April 19, 2016 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjurado01/295dd457e3c7736d45a86b50e688bf53 to your computer and use it in GitHub Desktop.
Save rjurado01/295dd457e3c7736d45a86b50e688bf53 to your computer and use it in GitHub Desktop.
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