title: Mongodb aggregation: insert nested fields in $group stage
body: <p>I'm trying to create some nested fields in <code>$group</code> stage of aggregation. I get the error that "stats" must be an accumulator. Is there any way to insert these nested fields?</p>
  
  <pre class="lang-js prettyprint-override"><code>model.aggregate( [ {
    $group: {
      _id: '$groupName,
      nestedFields: {
        field1: {
          $sum: { $multiply: [ '$num1', '$num2'] }
        },
        field2: { $sum: '$num3' }
      }
    }
  } ] )
  </code></pre>
  
  <p>Any help is greatly appreciated. </p>
  
  <p>edit: some sample data INPUT: </p>
  
  <pre><code>{
    "groupName": 1
    "num1": 2,
    "num2": 4,
    "num3": 8,
  }
  {
    "groupName": 1
    "num1": 2,
    "num2": 7,
    "num3": 1,
  }
  {
    "groupName": 2
    "num1": 1,
    "num2": 3,
    "num3": 5,
  }
  {
    "groupName": 2
    "num1": 6,
    "num2": 1,
    "num3": 2,
  }
  </code></pre>
  
  <p>should OUTPUT through the aggregation: </p>
  
  <pre><code>{
    "_id": 1,
    "nestedFields": {
      "field1": 22,      // 2*4 + 2*7
      "field2": 9,       // 8 + 1
    }
  },
  {
    "_id": 2,
    "nestedFields": {
      "field1": 9,      
      "field2": 7,       
    }
  }
  </code></pre>