title: Mongo Group By Condition and Count
body: <p>I have a data like this, what I'm trying to do is count the employee by grouping them with gender.</p>
  
  <pre><code>{
     _id: ObjectId("57fd6b064a8d7733079d1bb9"),
     name: "Alex",
     age: 23,
     position: "Manager",
     employees: [{
         _id: ObjectId("58056e62281b7a73dfdb6887"),
         employee_id: ObjectId("57df832364efef57c3540610"),
         name: "Bob",
         age: 20,
         gender: "Male",
         position: "Distributor"
     }, {
         _id: ObjectId("58049fe7bc82e44583c52a64"),
         employee_id: ObjectId("57df830264efef57c354060d"),
         name: "Cindy",
         age: 19,
         gender: "Female",
         position: "Administrator"
     }, {
         _id: ObjectId("58049fe7bc82e44583c52a64"), 
         employee_id: ObjectId("57df830264efef57c354060d"), 
         name: "Dylan",
         age: 21,
         gender: "Male",
         position: "Engineer"
    }]
  }
  </code></pre>
  
  <p>So, the data I'd like to have is like this</p>
  
  <pre><code>{
     _id: ObjectId("57fd6b064a8d7733079d1bb9"),
     name: "Alex",
     age: 23,
     position: "Manager",
     male_employees: 2,
     female_employees: 1,
  }
  </code></pre>
  
  <p>I've tried aggregate but still nothing close to what I want to have.
  I have no idea how to group them and use size at the same time</p>