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 with 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? 回答1: 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