Mongodb 根据数组中特定位置的项目进行查询

Mongodb query based on item at specific position in array

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

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

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

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

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

我尝试过的查询:

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

将您的查询更改为以下内容

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