title: Mongo aggregation - custom function to create field
body: <p>I'd like to be able to create a field as <code>newField = someFunction(currentDocument)</code>, but it looks like this is not supported. Is it? I know I can do this within the map reduce framework, but I need to stay within the aggregation framework atm. For some edge case, I can get things to work, for instance:</p>
  
  <pre><code>items.aggregate([
    {
      $project: {
        _tmp: ['$a', '$a', '$b'],
      },
    },
    {
      $unwind: '$_tmp',
    },
    {
      $group: {
        _id: '$_id',
        aab: { $sum: '$_tmp' }
      }
    },
  ]);
  </code></pre>
  
  <p>quite simply creates a fields that is equal to <code>2a+b</code> but that looks like overkill and inefficient.</p>