2011-07-17 28 views
1

有点像?我可以通过节点驱动程序访问mongo的geoNar功能吗?

db.open (err, client) -> 
    db.collection 'test', (err, collection) -> 
     collection.runCommand {geoNear:"loc", near:[50,50], $maxDistance:1}, #callback here? 
+0

显然,你可以做到这一点,但是从你的问题的语法是coffescript:http://groups.google.com/group/mongodb-user/browse_thread/thread/ 656d60c6d14d3f73?pli = 1 –

回答

6

我使用节点MongoDB的原生v0.9.3

它确实有geoNear支持。

使用此命令:

db.executeDbCommand({ geoNear : "CollectionName", near : [lat,lng], maxDistance : 10 }, function(err, result { // do something with results here}); 
+1

谢谢,我最终也找到了这个,但我刚刚使用'db.command({geoNear:'collection'......' – fancy

1

this post,节点驱动还没有实现为geoNear支持。然而,好消息是该文章提供了一个可能的实现,因此您可以使用该代码为您的项目实施geoNear

相关问题