title: How to collect array document values into parent document in MongoDB
body: <p>How to perform a similar aggregation to <em>LATERAL VIEW EXPLODE</em> and then selecting the columns you want in spark, but with mongodb?</p>
  
  <p>For example convert documents similar to:</p>
  
  <pre><code>{
      name: "john",
      surname: "doe",
      arr: [
          {
              itemName: "address",
              itemVal: "2333. Street"
          },{
              itemName: "phone",
              itemVal: "43098685446"
          }
      ]
  }
  </code></pre>
  
  <p>into a flat document:</p>
  
  <pre><code>{
      name: "john",
      surname: "doe",
      address: "2333. Street",
      phone: "43098685446"
  }
  </code></pre>