考虑以下作为聚合管道输出的文档:
{ "_id" : 1, "results" : [
{ "status" : "HOLD", "footage" : 43.01, "pieces" : 1 },
{ "status" : "ACCEPTED", "footage" : 80.90, "pieces" : 2 },
{ "status" : "REJECTED", "footage" : 40.00, "pieces" : 1 }
]}
我正在尝试创建将状态与镜头和片段字段连接起来的自定义键,结果:
{ "_id" : 1, "results" :
{
"HOLD_footage": 43.01,
"HOLD_pieces":1,
"ACCEPTED_footage": 80.90,
"ACCEPTED_pieces": 2,
"REJECTED_footage":40.00,
"REJECTED_pieces":1
}
}
答案 0 :(得分:0)
您可以执行以下操作:
describe(['QA'], 'Will tag every test inside the describe with the "QA" tag',
function () { ... });
it(['QA'], 'This is a work-in-progress test', function () { ... });
使用您想要的密钥构建 k-v 元组(即 HOLD_footage...)$map
对 k-v 元组数组进行分组$concatArrays
取回您期望的数组形式这是 Mongo playground 供您参考。