search

Home  >  Q&A  >  body text

如何mongoDB以数组中某元素的值的范围为条件查询?

{
  "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的数据

漂亮男人漂亮男人2757 days ago737

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-02 09:25:28

    Written like this, the subscripts for arrays start from 0. If the first value represents latitude

    db.collection.find({ "address.coord.0":{$lt:-95.754168} })

    reply
    0
  • Cancelreply