title: Mongodb sum all the same fields in array foreach document - Map-Reduce
body: <p>I have documents like this in my db:  </p>
  
  <pre><code>{
  "first_name": "John",
  "last_name": "Bolt",
  "account": [
    {
      "cardnumber": "4844615935257045",
      "cardtype": "jcb",
      "currency": "CZK",
      "balance": 4924.99
    },
    {
      "cardnumber": "3552058835710041",
      "cardtype": "jcb",
      "currency": "BRL",
      "balance": 9630.38
    },
    {
      "cardnumber": "5108757163721629",
      "cardtype": "visa-electron",
      "currency": "CNY",
      "balance": 6574.18
    }
  }
  </code></pre>
  
  <p>And my question is - how can I sum balances for all accounts foreach person separately? Should I use for this Map-Reduce or Aggregation Framework?</p>