Mongo find()查询工作不正常

时间:2016-05-10 20:59:46

标签: mongodb

下面是mongo文档,

db.south.find({station:"Stourton"})
{ "_id" : ObjectId("572cca5a9c850445fc6c3122"),
  "line" : { "map" : "north_image.jpg", "name" : "north" }, 
  "dep" : { "dep_timing" : 
                           [{ "time" : "09:50" }, 
                            { "time" : "11:50" },
                            { "time" : "12:50" },
                            { "time" : "13:50" },
                            { "time" : "14:50"},
                            { "time" : "15:50" },
                            { "time" : "16:50" }, 
                            { "time" : "17:50" },
                            { "time" :"18:50" }, 
                            { "time" : "19:50" }, 
                            { "time" : "20:50" },
                            { "time" : "21:50" },
                            { "time" : "22:55" } ], 
 "route" : [ { "station" : "CitySquare" } ] }, 
 "station" : "Stourton" }

我正在使用此查询来提取大于或等于" 09:50"的时间,

> db.south.find({dep:{dep_timing:{"time":"09:50"}}})

但没有结果输出。我是Mongodb的新手所以请帮忙。感谢

1 个答案:

答案 0 :(得分:0)

查询应该是这样的:

db.south.find({ "dep.dep_timing.time": "09:50"})

并将返回所有包含{"dep":{"dep_timing":{"time":"9:50"}}}

的文档

查看documentation