title: Is it possible to sum 2 fields in MongoDB using the Aggregation framework?
body: <p>I have a collection with documents that contain fields type, totalA and totalB</p>
  
  <p>I want to use the aggregation framework in order to group by type - and get the sum of both totalA and totalB together.</p>
  
  <p>The last thing I tried (doesn't work) is:</p>
  
  <pre><code>'$group' : { 
    '_id' : '$type', 
    'totalA' : { '$sum' : '$totalA' },
    'totalB' : { '$sum' : '$totalB' },
    'totalSum' : { '$sum' : '$totalA', '$sum' : '$totalB' },
  }  }
  </code></pre>
  
  <p>totalSum has the sum of only one of the fields instead of the combined value.</p>