title: The field must be an accumulator object in mongo
body: <p>I am performing an aggregation query.My requirement is that I have docs in following format:</p>
  
  <pre><code>{
  "name":"a","age":20},
  {
  "name":"b","age":23},
  {
  "name":"a","age":26}
  </code></pre>
  
  <p>I need to sum the ages of all names who have "a" in their name field.
  I am doing the following but it gives me an error that "The field 'name' must be an accumulator object":</p>
  
  <pre><code>db.collection('students').aggregate({
          $group: {"name": "a", "sum": {$sum: '$age'}}
      }, {
          $project: {sum: '$sum'}
      }, (e, d) =&gt; {
          if (!e) {
              var e = d.stream({transform: JSON.stringify});
              console.log("answer")
              console.log(e);
              deferred.resolve(e);
          } else {
              console.log(e)
          }
      })
  </code></pre>