开发者

Mongodb: return objects from document array

In the following collection, how would I return all documents, but remove objects from the foos array where bar != 'en'

{
    "name": "Item 1"
    "f开发者_StackOverflow中文版oos": [
        {
            "foo": "bar",
            "bar": "en"
        }
        {
            "foo": "bar",
            "bar": "fr"
        }
        {
            "foo": "bar",
            "bar": "en"
        }
    ]
}

Thanks


You cannot easily. You need this feature: http://jira.mongodb.org/browse/SERVER-1831


MongoDB hasn't support virtual collections。So you can not get the part of sub-documents.Now you can create new document which you want to get the part of sub-documents。See http://jira.mongodb.org/browse/SERVER-142

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜