wutzebaer
wutzebaer

Reputation: 14875

MongoDb find objects by array length

Hi i have an Object like this in my database

{
  "_id" : ObjectId("53a88d81a00456db9687fd1b"),
  "id" : NumberLong(381341),
  "version" : "14",
  "changeset" : "8658593",
  "uid" : "12919",
  "user" : "Cerritus",
  "timestamp" : "2011-07-07T15:47:09Z",
  "poly" : {
    "type" : "LineString",
    "coordinates" : [[8.5904504, 49.8634605], [8.5904517, 49.8634134], [8.5905602, 49.8624448], [8.5906698, 49.8616734], [8.5908094, 49.86097], [8.5908963, 49.8603052], [8.5909131, 49.8602373], [8.5909636, 49.8598595], [8.5910442, 49.859171]]
  },
  "highway" : "unclassified",
  "name" : "Flughafenstraße"
}

why does this query return nothing?

{'poly.coordinates.length': {$eq:7}}

Upvotes: 0

Views: 50

Answers (1)

wutzebaer
wutzebaer

Reputation: 14875

the correct query is

{"poly.coordinates": { $size: 7 }}

Upvotes: 1

Related Questions