0
我成功使用geoNear()獲得了所有具有距離的商店;如何在Mongoose中使用geoSearch獲得距離
我成功地使用geoSearch()獲取特殊類型的商店而不顯示我的距離。
如何列出特殊類型的商店以及向我展示距離?
Model.geoNear({
"type": "Point",
"coordinates": opts.coordinates
}, {
lean: true,
spherical: true,
includeLocs: true,
maxDistance: opts.radius/EARTH_RADIUS,
distanceMultiplier: EARTH_RADIUS
}, function(err, shops, stats) {
var results = exports.trimedDistance(shops);
deferred.resolve(results);
});
-
Model.geoSearch({
_category: mongoose.Types.ObjectId(opts.categoryId)
}, {
near: opts.coordinates,
lean: true,
limit: 10,
maxDistance: opts.radius/EARTH_RADIUS
}, function(err, shops) {
var results = exports.trimedDistance(shops);
deferred.resolve(results);
});