我有一个具有以下结构的json:
{"data": {
"key1": "value1",
"key2": "value2",
"manualTests": [{"name": "component1", "passed": false, "x": 12},
{"name": "component2", "passed": true},
{"name": "component3", "passed": false, "responseTime": 5}],
"automaticTests": [{"name": "component4", "passed": false},
{"name": "component5", "passed": true, "conversion": "Z"},
{"name": "component6", "passed": false}],
"semiautomaticTests": [{"name": "component7", "passed": true},
{"name": "component8", "passed": true},
{"name": "component9", "passed": true}]
}}
我的mongoDB包含大量此类文件,我需要获取未通过测试的所有组件的列表。因此所需的输出应为:
{
"component1": 150,
"component2": 35,
"component3": 17,
"component4": 5,
"component5": 3,
"component6": 1
}
数字是随机的,并且对于每个组件,它们显示有多少组件通过了测试。如何在mongoDB中计算它?格式不严格,主要要求是输出中应包含失败组件的名称及其在整个示例中的编号。