假设我有以下集合 -
{
date : "12-Apr-2017",
empID : "Emp1",
workDone : [4, 5 9], // ['job A', 'job B', 'Total Jobs']
},
{
date : "12-Apr-2017",
empID : "Emp2",
workDone : [2, 5, 7], // ['job A', 'job B', 'Total Jobs']
},
{
date : "13-Apr-2017",
empID : "Emp1",
workDone : [6, 4, 10], // ['job A', 'job B', 'Total Jobs']
}
我想要这样的输出 -
{
empID : "Emp1",
workDone : [10, 9, 19] // ['job A', 'job B', 'Total Jobs'] cumulative
},{
empID : "Emp2",
workDone : [2, 5, 7] // ['job A', 'job B', 'Total Jobs'] cumulative
}
如何在MongoDB聚合中按数组值添加值?