0
MongoidまたはMongoMapperのようなORMラッパーのないrubyドライバを使用して、mongodbにバウンディングボックスジオクエリーを発行する方法を解明しようとしています。MongoDB Ruby Bounds ORMなしのクエリ
私はnearコマンドを実行することはできますが問題はありませんが、内部でfindの構文を理解できないようです。
box = [[34.05,-118.24],[35.80,116.44]]
coll = db.command({'within' => "sites", 'box' => box}
または
:私は半径conn = Mongo::Connection.from_uri('my DB')
db = conn.db('my_sites')
coll = db.command({'geoNear' => "sites",
'near'=>[lng,lat],
'spherical' => true,
'maxDistance' => distance_in_radians,
'num' => limit})
render :json => coll['results'].to_a
以内に照会したい。しかし、私は右の内のクエリを得ることに困惑していた場合
はこれが作品の魅力のように
db['my_sites']
coll = db.find({"box" => box})
私はmongoクライアントで直接問合せを発行できますが、私はRubyドライバの構文を理解しています。