How to query mongoDB based on the range of the value of an element in an array?
漂亮男人
漂亮男人 2017-05-02 09:23:28
0
1
741
{
  "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"
}

How to query data whose latitude in coord is less than -95.754168

漂亮男人
漂亮男人

reply all(1)
世界只因有你

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} })
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template