Query.prototype.geometry()
Parameters
- object «Object» Must contain a
type
property which is a String and acoordinates
property which is an Array. See the examples.
Returns:
- «Query» this
Specifies a $geometry
condition
Example
const polyA = [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]]
query.where('loc').within().geometry({ type: 'Polygon', coordinates: polyA })
// or
const polyB = [[ 0, 0 ], [ 1, 1 ]]
query.where('loc').within().geometry({ type: 'LineString', coordinates: polyB })
// or
const polyC = [ 0, 0 ]
query.where('loc').within().geometry({ type: 'Point', coordinates: polyC })
// or
query.where('loc').intersects().geometry({ type: 'Point', coordinates: polyC })
The argument is assigned to the most recent path passed to where()
.
NOTE:
geometry()
must come after either intersects()
or within()
.
The object
argument must contain type
and coordinates
properties. - type {String} - coordinates {Array}
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .