2015-02-09 34 views
0

我想运行一个查询,其中需要比较数组中特定位置的项。基于数组中特定位置的项的Mongodb查询

例如,考虑用于存储位置数据的GeoJSON格式。

//sample document from collection user 
{ 
    name: "Some name", 
    location : { 
     type: "Point", 
     coordinates : [<Longitude>, <Latitude>] 
    } 
} 

如何查询位于特定经度的用户?

我似乎在文档中找不到任何可以帮助我做同样的事情。

查询我曾尝试:

db.users.find({"location.coordinates[0]" : -73.04303}) 

回答

3

查询更改为以下

db.users.find({"location.coordinates.0" : -73.04303}) 
相关问题