2014-11-04 57 views
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); 
}); 

回答