Using Mongo Geospatial queries on lots of data Using Mongo Geospatial queries on lots of data mongoose mongoose

Using Mongo Geospatial queries on lots of data


What you can probably do, is to make an aggregate function with a lookup, I did not test it, and I don't know for sure if it is a better performance, but you can do something similar to the following:

let pipeline = [        {            $geoNear: {                includeLocs: "location",                distanceField: "distance",                near: { type: 'Point', coordinates: "$$point" },                maxDistance: 20,                spherical: true            }        }    ];UsersModel.aggregate([{   $lookup : {     from : 'locations',     let : {point : '$address'}, //whatever the field for the coordinates is      pipeline ,     as : 'places'      }}])