我成功地使用geoNear()让所有商店都有距离;
我成功地使用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);
});
答案 0 :(得分:0)
解决。
使用geoNear Aggregate http://docs.mongodb.org/manual/reference/operator/aggregation/geoNear/