Can I access the geoNear functionality of mongo via the ruby driver?
I'm retrieving results from mongo based on a geo query using the ruby driver. I'd like the results to be returned 开发者_如何学Gowith their respective distances. That facility is available at the shell using geoNear command:
db.runCommand( { geoNear : "places", near : [50,50], num : 10 } );
How do I do this via the ruby API?
where db
is the connection to your db you can use #command
:
db.command({'geoNear' => "places", 'near'=>[50,50], 'num' => 10})
This has to be an OrderedHash
in ruby 1.8, hashes are ordered in 1.9 so you are all good with default hash if using 1.9
精彩评论