如何mongoDB以数组中某元素的值的范围为条件查询?
漂亮男人
漂亮男人 2017-05-02 09:23:28
0
1
733
{
  "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的数据

漂亮男人
漂亮男人

Antworte allen(1)
世界只因有你

这样写,数组的话下标从0开始。如果第一个值代表纬度的话

db.collection.find({ "address.coord.0":{$lt:-95.754168} })
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage