Can I access geoNear features for mongo through the ruby ​​driver?

I am extracting results from mongo based on geo-query using ruby ​​driver. I would like the results to be returned with their respective distances. This tool is available in the shell using the geoNear command:

db.runCommand( { geoNear : "places", near : [50,50], num : 10 } );

How to do it using ruby ​​API?

+3
source share
1 answer

where dbis the connection to your db, you can use #command:

  db.command({'geoNear' => "places", 'near'=>[50,50], 'num' => 10})

This should be OrderedHashin ruby ​​1.8, hashes are ordered in 1.9, so you can use the default hash when using 1.9

+3
source

All Articles