如何mongoDB以數組中某元素的值的範圍為條件查詢?
漂亮男人
漂亮男人 2017-05-02 09:23:28
0
1
756
{
  "address": {
     "building": "1007",
     "coord": [ -73.856077, 40.848447 ],
     "street": "Morris Park Ave",
     "zipcode": "10462"
  },
  "borough": "Bronx",
  "cuisine": "Bakery",
  "grades": [
     { "date": { "$date": 1393804800000 }, "grade": "A", "score": 2 },
     { "date": { "$date": 1378857600000 }, "grade": "A", "score": 6 },
     { "date": { "$date": 1358985600000 }, "grade": "A", "score": 10 },
     { "date": { "$date": 1322006400000 }, "grade": "A", "score": 9 },
     { "date": { "$date": 1299715200000 }, "grade": "B", "score": 14 }
  ],
  "name": "Morris Park Bake Shop",
  "restaurant_id": "30075445"
}

如何查詢符合coord中緯度小於-95.754168的資料

漂亮男人
漂亮男人

全部回覆(1)
世界只因有你

這樣寫,陣列的話下標從0開始。如果第一個值代表緯度的話

db.collection.find({ "address.coord.0":{$lt:-95.754168} })
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板