2014-06-23 63 views
0

你好MongoDB的找對象我有一個這樣的對象在我的數據庫由數組長度

{ 
    "_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" 
} 

爲什麼這個查詢任何回報?

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

回答

1

正確的查詢是

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