2011-07-17 31 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

相關問題