Location.find({
loc: {
$near: {
$geometry: {
type: "Point",
coordinates: coords
},
$maxDistance: maxDistance
}
}
}).then((err, locations) => {
// do what you want here
})
var locQuery = (coords, distance) => {
return { loc: { $near: { $geometry: { type: "Point", coordinates: coords }, $maxDistance: parseInt(distance)}}}
}