Field not showing in Mongoose aggregation

后端 未结 1 552
闹比i
闹比i 2021-01-25 21:20

I\'m trying to get a count of all distinct departments. I\'d like the results to contain the deptType, deptName and the count. The grouping works, and results show deptType and

相关标签:
1条回答
  • 2021-01-25 21:51

    Sorry guys that was silly:

    (...)
    $group: {
        _id : { dType : "$departments.deptType", 
                dName : "$departments.deptName" 
              },
       dCount: { $sum: 1 },
    }
    (...)
    
    0 讨论(0)
提交回复
热议问题