Skip to content

Instantly share code, notes, and snippets.

@itsabdessalam
Last active December 4, 2019 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save itsabdessalam/10c916f8089673e18ed27c5cdae0599d to your computer and use it in GitHub Desktop.
Save itsabdessalam/10c916f8089673e18ed27c5cdae0599d to your computer and use it in GitHub Desktop.
StoreSchema.statics.findByCoordinates = function(coordinates, maxDistance) {
return this.aggregate([
{
$geoNear: {
near: {
type: "Point",
coordinates: coordinates
},
maxDistance: maxDistance,
distanceField: "dist.calculated",
spherical: true
}
}
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment