title: Using $sum to calculate the total value in a object, mongoose/mongodb
body: <p>I have this:</p>
  
  <pre><code>var actions = [
    project: 23123,
    title: 'Change of windows
    energySaving: {
        electricity: {
          lighting: 24324,
          equipment: 23423,
          fans: 234234,
          distribution: 234324,
          chiller: 234234,
          other: 234324
        },
        heating: {
          ventilation: 234324,
          shell: 23423,
          tapWater: 23423
        },
    }
  ]);
  </code></pre>
  
  <p>This is my query to get some fields from the actions collection:</p>
  
  <pre><code>mongoose.model('Action').find({project: project._id})
    .select('title description energySaving')
  
        .exec(function(err, actions){
        res.status(200).send(actions);
      });
    })
  </code></pre>
  
  <p>Instead of getting the entire "energySaving" property, I would like to replace this with a "totalEnergySaving" which is the sum of all the subobjects. Is it possible to use a aggregation to do this? If so, it's probably the <code>$sum</code> feature. Not really sure how though. </p>