【问题标题】:mongomapper geospatial 'within' querymongomapper 地理空间“内部”查询
【发布时间】:2012-04-08 20:48:24
【问题描述】:

我正在尝试使用 mongomapper 进行“内部”查询。当我在 shell 中执行命令时,一切正常:

box = [[32.476750,-117.246094],[32.850173,-116.806641]]
db.locations.find({"location" : {"$within" : {"$box" : box}}})
// Bunch of results

但是,当我在 rails 控制台中运行相同的命令时,我得到了 nil:

box = [[32.476750,-117.246094],[32.850173,-116.806641]]
Location.find(:location => {"$within" => {"$box" => box}})
 => nil 

如果我做 Location.first 我会得到一个位置,所以我知道我指向正确的数据库集合。我的 mongomapper 查询返回 0 结果有什么问题?

【问题讨论】:

    标签: mongodb geospatial mongomapper


    【解决方案1】:

    啊,我想通了。我没有使用“find”,而是使用了“where”。现在我得到了正确的结果集。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-07
      • 2013-09-25
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      • 2019-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多