我可以通过节点驱动程序访问mongo的geoNearfunction吗?
就像是?
db.open (err, client) -> db.collection 'test', (err, collection) -> collection.runCommand {geoNear:"loc", near:[50,50], $maxDistance:1}, #callback here?
我正在使用node-mongodb-native v0.9.3
它支持geoNear。
使用这个命令:
db.executeDbCommand({ geoNear : "CollectionName", near : [lat,lng], maxDistance : 10 }, function(err, result { // do something with results here});
根据这个post ,节点驱动程序还没有实现对geoNear
支持。 不过,好消息是post提供了一个可能的实现,所以你可以使用该代码来为你的项目实现geoNear
。