title: MongoDB - Aggregate Sum
body: <p>I am attempting to calculate the total amount of money spent being tracked inside of our database. Each order document contains a field "total_price"</p>
  
  <p>I am attempting to use the following code:</p>
  
  <pre><code>db.orders.aggregate({
      $group: {
          _id: null,
          total: {$sum: "$total_price"}
      }
  })
  </code></pre>
  
  <p>Unfortunately, the only output I get is: <code>{ "result" : [ { "_id" : null, "total" : 0 } ], "ok" : 1 }</code></p>
  
  <p>But to verifiy there is actually numerical data stored, and just not being totaled: <code>db.orders.find()[0].total_price</code> this results in <code>8.99</code></p>
  
  <p>Any help would be greatly appreciated. I have very little experience using MongoDB. I've only covered the basics at this point.</p>
  
  <p>Thank you in advance.</p>