在MongoDB上,我有一个这样的集合:-
{
org: "org",
departments: [
{
name: "abc",
employees: [
{ name: "number1" },
{ name: "number2" },
{ name: "number3" },
]
},
{
name: "mno",
employees: [
{ name: "number4" },
{ name: "number5" }
]
},
{
name: "xyz",
employees: [
{ name: "number6" },
{ name: "number7" }
]
}
]
},{
org: "xyz"....
}
如何通过使用汇总查找“组织”中的雇员总数? 期待结果 { org:“ org”, 员工总数:7 }, { org:“ xyz”, 员工总数:x } ..