title: MongoDB Aggregation Multiple Keys
body: <p>I trying to aggregate employees using department and status to calculate summ for each status. From this:</p>
  
  <pre><code>{
    name : "Employee_1",
    department: "hr",
    status : "exist"
  },
  {
    name : "Employee_2",
    department: "acme",
    status : "absent"
  },
  {
    name : "Employee_3",
    department: "acme",
    status : "absent"
  }
  ...
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>{
    department: "hr",
    statuses: {
      exist: 1,
      absent: 0
    }
  },
  {
    department: "acme",
    statuses: {
      exist: 0,
      absent: 2
    }
  }
  ...
  </code></pre>
  
  <p>I was try to do it via:</p>
  
  <pre><code>Employee.aggregate(  
          { $group: {
              _id: '$department',
              statuses: { $addToSet: "$status" }
          }},
          { $project: { _id: 1, statuses: 1 }},
          function(err, summary) {
              console.log(summary);
          }
      );
  </code></pre>
  
  <p>I get only statuses in array, produced by "$addToSet":</p>
  
  <pre><code>{
    department: "hr",
    statuses: [
        'exist',
        'absent'
    ]
  },
  {
    department: "acme",
    statuses: [
        'exist',
        'absent'
    ]
  }
  ...
  </code></pre>
  
  <p>How to right put "{$sum: 1}" for each of statuses? Thank for you'r response.</p>