{ “shellList”: [ { “bookId”: “168”, “readPagePercent”: “0”, “createTime”: “2014-01-21 16:17:33”, “readType”: “1” }, { “bookId”: “168”, “readPagePercent”: “2”, “createTime”: “2014-02-21 16:17:33”, “readType”: “2” } , { “bookId”: “169”, “readPagePercent”: “2”, “createTime”: “2014-02-21 16:17:33”, “readType”: “2” } , { “bookId”: “170”, “readPagePercent”: “2”, “createTime”: “2014-02-21 16:17:33”, “readType”: “2” } ], “userId”: “100002” } 我怎查出 bookid为168的文档呢 求指导
db.collection.find({},{‘shellList’:{$elemMatch:{‘bookId’:‘168’}}})只能查出一条 但是我希望符合条件的都查出来,好诡异的查询。 mongodb 有个$slice ,可以把数组劈开,既然这样可以,那应该有条件查询相关的解决方法