3

我有一个包含“嵌套”文档的 mongodb 集合。例如,文档可以具有以下结构:

{
    "condition": {
        "parameter": {
            "type": "person"
        }
    }
}

以及下一个:

{
    "condition": {
        "conditions": [
            {
                "conditions": [
                    {
                        "parameter": {
                            "type": "A"
                        }
                    },
                    {
                        "parameter": {
                            "type": "B"
                        }
                    }
                ]
            },
            {
                "parameter": {
                    "type": "C"
                }
            }
        ]
    }
}

意思是,每个条件子文档本身可以有多个条件。

现在,我想对type每个条件的字段进行“递归”查询,例如('..' 表示递归):

{
    "$or": [
        {"condition.type": "person"},
        {"condition..conditions.type": "person"}
    ]
}

有没有办法在 Mongo 中做到这一点?

4

0 回答 0