title: Insert element into nested arrays in MongoDB
body: <p>I am new to mongoDB. I am having some trouble in updating the records in mongoDB collection.</p>
  <p>How to add elements into array <code>likes</code> into the embedded record</p>
  <p>I have a embedded collection like:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;_id&quot;: &quot;iL9hL2hLauoSimtkM&quot;,
    &quot;title&quot;: &quot;Some Topic&quot;,
    &quot;followers&quot;: [
      &quot;userID1&quot;,
      &quot;userID2&quot;,
      &quot;userID3&quot;
    ],
    &quot;comments&quot;: [
      {
        &quot;comment&quot;: &quot;Yes Should be....&quot;,
        &quot;userId&quot;: &quot;a3123&quot;,
        &quot;likes&quot;: [
          &quot;userID1&quot;,
          &quot;userID2&quot;
        ]
      },
      {
        &quot;comment&quot;: &quot;No Should not be....&quot;,
        &quot;userId&quot;: &quot;ahh21&quot;,
        &quot;likes&quot;: [
          &quot;userID1&quot;,
          &quot;userID2&quot;,
          &quot;userID3&quot;
        ]
      }
    ]
  }
  </code></pre>
  <p>I want to update the record as</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;_id&quot;: &quot;iL9hL2hLauoSimtkM&quot;,
    &quot;title&quot;: &quot;Some Topic&quot;,
    &quot;followers&quot;: [
      &quot;userID1&quot;,
      &quot;userID2&quot;,
      &quot;userID3&quot;
    ],
    &quot;comments&quot;: [
      {
        &quot;comment&quot;: &quot;Yes Should be....&quot;,
        &quot;userId&quot;: &quot;a3123&quot;,
        &quot;likes&quot;: [
          &quot;userID1&quot;,
          &quot;userID2&quot;,
          &quot;userID3&quot; // How to write query to add this element.
        ]
      },
      {
        &quot;comment&quot;: &quot;No Should not be....&quot;,
        &quot;userId&quot;: &quot;ahh21&quot;,
        &quot;likes&quot;: [
          &quot;userID1&quot;,
          &quot;userID2&quot;,
          &quot;userID3&quot;
        ]
      }
    ]
  }
  </code></pre>
  <p>Please provide the query to add the element shown in comment.
  Thank you.</p>