# [Command](/minigame/dev/wxcloud/reference-sdk-api/database/Command).geoNear(options: Object): [Command](/minigame/dev/wxcloud/reference-sdk-api/database/Command)

> 支持端：[小程序](/miniprogram/dev/framework/client-lib/version.md), [云函数](/minigame/dev/wxcloud/reference/changelog-server-sdk), [Web](/minigame/dev/wxcloud/reference/changelog-web-sdk)

按从近到远的顺序，找出字段值在给定点的附近的记录。

## 参数

### options: Object

| 属性 | 类型 | 默认值 | 必填 | 说明 |
| ---- | ---- | ------ | -------- | ---- |
| geometry | [GeoPoint](/minigame/dev/wxcloud/reference-sdk-api/database/geo/GeoPoint) |  | 是 | 地理位置点 (Point) |
| maxDistance | number |  | 否 | 选填，最大距离，单位为米 |
| minDistance | number |  | 否 | 选填，最小距离，单位为米 |

## 返回值

### [Command](/minigame/dev/wxcloud/reference-sdk-api/database/Command)

## 索引要求

需对查询字段建立地理位置索引

## 示例代码

找出离给定位置 1 公里到 5 公里范围内的记录

```js
const _ = db.command
db.collection('restaurants').where({
  location: _.geoNear({
    geometry: db.Geo.Point(113.323809, 23.097732),
    minDistance: 1000,
    maxDistance: 5000,
  })
}).get()
```
