title: Using Mongo DB how do I get the sum of all related fields in a different collection
body: <p>I have two collections. One collection stores user data and another collection stores transaction data. The transaction data references user data using a foreign field on the user id.</p>
  <p>How would I go about getting all user data with one additional field which is the sum of all linked transaction on the amount field?</p>
  <p>The user model consist of id and various other fields e.g.</p>
  <pre><code>{
    id: unique_mongo_id
    name: Tom
    ...
  }
  </code></pre>
  <p>The transaction table consists of two main fields which is a reference to the user Id and the value of the transaction e.g.</p>
  <pre><code>{
    userId: unique_mongo_user_id
    amount: 100
    ...
  }
  </code></pre>
  <p>The output I am trying to achieve is a simple get of all user fields with one additional field which is the sum of all transactional data.</p>
  <p>Many thanks for your help on this!</p>