title: MongoDB $project embedded document to root level
body: <p>Using the aggregate pipeline, I am trying to project an embedded document to the root level <strong>WITHOUT projecting each field individually.</strong></p>
  
  <p>For example, I want to project <code>name</code> from this collection to the root level:</p>
  
  <pre><code>[
      {
          _id: "1",
          name: {
              firstName: "John",
              lastname: "Peters"
          }
      },
      {
          _id: "2",
          name: {
              firstName: "Mary",
              lastname: "Jones"
          }
      }
  ]
  </code></pre>
  
  <p>This is what I am looking for:</p>
  
  <pre><code>[
      {
          firstName: "John",
          lastname: "Peters"
      },
      {
          firstName: "Mary",
          lastname: "Jones"
      }
  ]
  </code></pre>
  
  <p>Is there a way to do this without projecting each field individually? I don't want to have to do this:</p>
  
  <pre><code>db.collection.aggregate(
      [
          {
              $project : {
                  "_id" : 0,
                  "firstName" : "$name.firstName",
                  "lastName" : "$name.lastName"
              }
          }
      ]
  </code></pre>