# db.command.geoIntersects
To set up a geographical location index for the queried field
Finds out the records in which the given geographical location graph is intersected
Method signature:
function geoIntersects(IOptions): Command
interface IOptions {
geometry: Point | LineString | MultiPoint | MultiLineString | Polygon | MultiPolygon // Geographical location
}
Sample code: Find out the records in which the geographical location graph intersects a polygon.
const db = wx.cloud.database()
const _ = db.command
const { Point, LineString, Polygon } = db.Geo
db.collection('restaurants').where({
location: _.geoIntersects({
geometry: Polygon([
LineString([
Point(0, 0),
Point(3, 2),
Point(2, 3),
Point(0, 0)
])
]),
})
})