# Command.geoNear(options: Object): Command

支持端:小程序 , 云函数 , Web

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

# 参数

# options: Object

属性 类型 默认值 必填 说明
geometry GeoPoint 地理位置点 (Point)
maxDistance number 选填,最大距离,单位为米
minDistance number 选填,最小距离,单位为米

# 返回值

# Command

# 索引要求

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

# 示例代码

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

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