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:
const options = { near: [10, 10], maxDistance: 5 };
Locations.geoSearch({ type : "house" }, options, function(err, res) {
console.log(res);
});
Options:
near
{Array} x,y point to search formaxDistance
{Number} the maximum distance from the point near that a result can belimit
{Number} The maximum number of results to returnlean
{Object|Boolean} return the raw object instead of the Mongoose Model
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .