Query.prototype.within()

Returns:
  • «Query» this

Defines a $within or $geoWithin argument for geo-spatial queries.

Example

  1. query.where(path).within().box()
  2. query.where(path).within().circle()
  3. query.where(path).within().geometry()
  4. query.where('loc').within({ center: [50,50], radius: 10, unique: true, spherical: true });
  5. query.where('loc').within({ box: [[40.73, -73.9], [40.7, -73.988]] });
  6. query.where('loc').within({ polygon: [[],[],[],[]] });
  7. query.where('loc').within([], [], []) // polygon
  8. query.where('loc').within([], []) // box
  9. query.where('loc').within({ type: 'LineString', coordinates: [...] }); // geometry

MUST be used after where().

NOTE:

As of Mongoose 3.7, $geoWithin is always used for queries. To change this behavior, see Query.use$geoWithin.

NOTE:

In Mongoose 3.7, within changed from a getter to a function. If you need the old syntax, use this.