Mongodb $ redact - 获取分层路径

时间:2014-07-10 09:51:39

标签: mongodb aggregation-framework

$redact管道中,是否可以知道当前文档所在的数组?例如,假设在以下文档结构上运行$redact管道:

arrayOut : [
    ...
    arrayIn1: [
        ...
    ],
    arrayIn2: [
        ...
    ]
]

我想知道该文件是否在arrayIn1下处理。我试过以下,但没有运气:

redact :{
    $cond :{
        "if": {
            $or : [
                { $eq : ["$$CURRENT" , "$$ROOT"] }, // match the most outer structure
                { $setIsSubset : [["$$CURRENT"] , "$$ROOT.arrayIn1"] } // never true
                ]
            },
        "then" : "$$DESCEND",
        "else" : "$$PRUNE"
         }        
    }      
}

0 个答案:

没有答案