我的mongodb集合中的文档中有一个地理编码,我需要从手中的两个地理编码返回到该地理编码的距离。我已经尝试了$ geoNear,但是不能在聚合查询中使用两个$ geoNear。请帮忙。
Route.aggregate([
{
$geoNear: {
near: first_route.origin.geocode,
spherical: true,
distanceField: "origin.distance",
key: "origin.geocode"
}
} ], function (err, data) {
//console.log(data);
if (err) {
res.json(err);
}
res.json(data);
});