db.command.geoNear

需对查询字段建立地理位置索引

按从近到远的顺序,找出字段值在给定点的附近的记录。

方法签名:

function geoNear(IOptions): Command

interface IOptions {
  geometry: Point // 点的地理位置
  maxDistance?: number // 选填,最大距离,单位为米
  minDistance?: number // 选填,最小距离,单位为米
}

示例:找出离给定位置 1 公里到 5 公里范围内的记录

const db = wx.cloud.database()
const _ = db.command
db.collection('restaurants').where({
  location: _.geoNear({
    geometry: db.Geo.Point(113.323809, 23.097732),
    minDistance: 1000,
    maxDistance: 5000,
  })
})

个结果 ""

    没有找到相关内容 ""