开发者

Mongodb: return objects from document array

开发者 https://www.devze.com 2023-02-16 19:06 出处:网络
In the following collection, how would I return all documents, but remove objects from the foos array where bar != \'en\'

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

精彩评论

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