为什么Command.geoNear(options: Object)这个接口不起作用?
发布于 5 年前 作者 xiulangu 8851 次浏览 来自 官方Issues

在云函数中调用这个接口,如果设置minDistance = 0;maxDistance=5000,返回的个数是0。如果不设置minDistance和maxDistance, 返回的又是全部的点位。请问是什么原因?

return await targetDB.where({

        location: _.geoNear({

          geometry: db.Geo.Point(event.longitude, event.latitude),

          // minDistance: event.minDistance,

          // maxDistance: event.maxDistance

        }),

      }).get()


2 回复

你好,测试正常,这边给你几个排查方向:

1、确认下数据库是否添加了索引

2、确认下数据库权限

3、确认下设定的查询范围和当前位置的距离是否有偏差

4、用真机测试

5、附上我的代码和测试结果

是不是没有建索引?

回到顶部