title: Flatten a nested JSON structure in mongoDB
body: <p>I have an object stored in MongoDB which looks like:</p>
  
  <pre><code>{
  _id: 123
  name: "xyz"
      attrib: 
      {
         address: "123 xyz rd",
         phone: "123-456-7890"
      }
  }
  </code></pre>
  
  <p>I want to flatted this structure, so that there is no <code>attrib</code> field, I just have <code>address</code> and <code>phone</code> field along with <code>name</code> and <code>_id</code>.</p>
  
  <p>So far, this is what I've tried:</p>
  
  <pre><code>db.emp.aggregate(
      { 
      $project : {
              { addr : '$review.attrib.address' },
              { phn : '$review.votes.phone' },
          }
      }
  );
  </code></pre>
  
  <p>Can anyone help me further?</p>