title: How to sum values of object fields when they placement in array MongoDB
body: <p>There is collection with objects each of whose includes array of objects whose fields I need to count. How the best way to do this? <strong>I need to sum only bar2 values</strong></p>
  <pre><code>{
        foo: [
         { bar1: 10, bar2: 20},
         { bar1: 10, bar2: 20},
         { bar1: 10, bar2: 20},
         { bar1: 10, bar2: 20}
        ]
  },
  
  {
        foo: [
         { bar1: 10, bar2: 20},
         { bar1: 10, bar2: 20},
         { bar1: 10, bar2: 20},
         { bar1: 10, bar2: 20}
        ]
  }
  </code></pre>