Model.geoSearch()

Parameters
  • conditions «Object» an object that specifies the match condition (required)

  • options «Object» for the geoSearch, some (near, maxDistance) are required

  • [options.lean] «Object|Boolean» if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See Query.lean() and the Mongoose lean tutorial.

  • [callback] «Function» optional callback

Returns:
  • «Promise»

Implements $geoSearch functionality for Mongoose

This function does not trigger any middleware

Example:

  1. const options = { near: [10, 10], maxDistance: 5 };
  2. Locations.geoSearch({ type : "house" }, options, function(err, res) {
  3. console.log(res);
  4. });

Options:

  • near {Array} x,y point to search for
  • maxDistance {Number} the maximum distance from the point near that a result can be
  • limit {Number} The maximum number of results to return
  • lean {Object|Boolean} return the raw object instead of the Mongoose Model