title: $replaceRoot of embedded document inside an array in MongoDB
body: <p>I am fairly new to MongoDB and I came across the <a href="https://docs.mongodb.com/manual/reference/operator/aggregation/replaceRoot/" rel="nofollow noreferrer">$replaceRoot(aggregation)</a> which I need to output the document the way I need it.</p>
  
  <p><strong>Document Schema</strong></p>
  
  <pre><code>{
  name: "Apple",
  image: "",
  is_fruit: true,
  other: [
    {
      url: "",
      quotes: { // saved as ObjectId and is then lookedup or populated
      text: "An apple a day keeps the doctor away"
    }
  }
  ]
  }
  </code></pre>
  
  <p><strong>Wanted Output</strong></p>
  
  <pre><code>{
    name: "Apple",
    image: "",
    is_fruit: true,
    other: [
      {
        text: "An apple a day keeps the doctor away"
      },
    ...
    ]
    }
  </code></pre>
  
  <p>i.e: To make quotes field as the root of the other array and not the root of entire document.</p>
  
  <p>Thank you.</p>