title: Using MongoDB Group on embedded documents
body: <p>My document <em>used to</em> look like this:</p>
  
  <pre><code>{
    _id : 47cc67093475061e3d95369d, 
    Name : "A name", 
    Description  : "Some description",
    DisciplineCode  : "105",
    DisciplineName  : "A Name",
    OtherProperty : "Something"
  }
  </code></pre>
  
  <p>For which, the following group command worked, in order to get the distinct DisciplineNames and DisciplineCodes from my documents</p>
  
  <pre><code>disciplines = db.result.group({ 
      key: {DisciplineName:1, DisciplineCode:1}, 
      reduce: function(obj, prev) { if (!obj.hasOwnProperty("DisciplineName")) { 
          prev.DisciplineName = obj.DisciplineName; 
          prev.DisciplineCode = obj.DisciplineCode; 
      }}, 
      initial: { } 
  });
  </code></pre>
  
  <p>However, my document has now changed to:</p>
  
  <pre><code>{
    _id : 47cc67093475061e3d95369d, 
    Name : "A name", 
    Description  : "Some description",
    Discipline: {
      Code  : "105",
      Name  : "A Name"},
    OtherProperty : "Something"
  }
  </code></pre>
  
  <p>As you can see, <code>Discipline</code> is an embedded doc.</p>
  
  <p>How can I modify my group command to still do the same?</p>