how to find geopoints radius in mongoose 1

how to find geopoints radius in mongoose

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

Here is what the above code is Doing:
1. We’re using the $near operator to find all documents that are within a certain distance of a point.
2. We’re using the $geometry operator to specify the point we’re interested in.
3. We’re using the $maxDistance operator to specify the maximum distance from the point we’re interested in.

Similar Posts