Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@giobyte8
Created November 26, 2014 03:44
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 giobyte8/7b90542e0d10d7aea628 to your computer and use it in GitHub Desktop.
Save giobyte8/7b90542e0d10d7aea628 to your computer and use it in GitHub Desktop.
/**
* Search all places in 'stores' collection that be 'near' of a given
* coordinates within a max distance of 2000 meters. collection 'stores'
* has a 2DSphere index on 'location'
*/
db.stores.find({
location: {
$near: {
$geometry: {
type: "Point",
coordinates: [ -123.528, 37.427] // Coordinates for 'hover tower' in Palo Alto
},
$maxDistance: 2000
}
}
}).pretty();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment