【问题标题】:geoNear Callback?geoNear 回调?
【发布时间】:2011-10-06 18:59:35
【问题描述】:

我有一个名为 test 的集合,我想使用 geoNear 进行查询。二维索引设置在字段 loc 上。

我在这里正确使用 db.runCommand 吗?

db.open (err, client) ->
    db.collection 'test', (err, collection) ->
        db.runCommand {geoNear:"loc", near:[50,50], $maxDistance:1}, #callback here? what params?

我通常会执行.toArray (err, docs) -> 之类的操作,然后使用找到的文档,但是在使用 geoNear 时我应该如何实现回调?它已经返回了一个带有元数据的对象,对吧?如何访问它?

非常感谢!

【问题讨论】:

    标签: mongodb node.js geolocation geospatial coffeescript


    【解决方案1】:

    是的,使用:

    db.command(参数,回调)

    【讨论】:

      猜你喜欢
      • 2017-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多