【发布时间】:2015-12-04 09:56:02
【问题描述】:
我正在尝试显示两个坐标之间的距离。下面的查询按预期执行并给出结果
db.runCommand( { geoNear: "distances",
near: [ 83.307974, 17.716456],
spherical: true
} );
我想从 nodejs 脚本执行这个查询。我正在使用猫鼬。 我尝试了聚合函数,但未能获得结果。谁能指导我正确的道路!
我试过这个:
db.getCollection('distances').aggregate([
{
"$geoNear": {
"near": {
"type": "Point",
"locc": [83.307974, 17.716456]
},
"distanceField": "distance",
"spherical": true
}
}
]);
参考资料:
【问题讨论】:
标签: node.js mongodb mongoose geospatial