簡體   English   中英

基於數組中特定位置的項目的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})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM