mongodb-erlang icon indicating copy to clipboard operation
mongodb-erlang copied to clipboard

how to use command with this driver with geoNear query?

Open JoyCood opened this issue 10 years ago • 2 comments

mongodb office command lilke below: db.runCommand( { geoNear: , near: { type: "Point" , coordinates: [ ] } , spherical: true, ... } ) http://docs.mongodb.org/manual/reference/command/geoNear/

how to do the same with mongodb-erlang driver?

JoyCood avatar Feb 10 '15 07:02 JoyCood

Use this as a selector : { '$near' , { '$geometry', { 'type', <<"Point">>, 'coordinates', [Latt, Long] } , '$maxDistance', Max} }

TheSquad avatar Feb 18 '15 00:02 TheSquad

If the "Max" here instead were to be defined by a property in the document (as being discussed for instance here: https://stackoverflow.com/questions/35329898/how-to-use-a-document-property-for-maxdistance-in-a-nearsphere-query). Would there still be a way to make such a query with mongodb-erlang? The "aggregate" function is not exposed, am I right?

peffis avatar Nov 10 '17 14:11 peffis