title: MongoDB aggregating from objects in array to object by specific field
body: <p>I would like to convert this type of document (objects in array):</p>
  
  <pre><code>[{"name": "david", "props": {"prop1": {"AR": 9, "NY": 8}, "prop2": 
  {"AR": 10, "NY": 9}}},
  {"name": "john", "props": {"prop1": {"AR": 7, "NY": 8}, "prop2": {"AR": 
  8, "NY": 9}}}]
  </code></pre>
  
  <p>into this one (filtering by the 'AR' field):</p>
  
  <pre><code>{"david": {"prop1": 9, "prop2": 10}, "john": {"prop1": 7, "prop2": 8}}
  </code></pre>
  
  <p>using MongoDB aggregations. Any thoughts?</p>