title: Embedded array insert in MongoDB
body: <p>For practice purposes, I have 3 users which I have inserted into my database.</p>
  <p>JSON code:</p>
  <pre><code>[
      {
      &quot;f_name&quot;: &quot;Raf&quot;, 
      &quot;l_name&quot;:&quot;Bak&quot;, 
      &quot;age&quot;: 19, 
      },
      {
      &quot;f_name&quot;:&quot;miltos&quot;,
      &quot;l_name&quot;:&quot;Bak&quot;, 
      &quot;age&quot;: 56,
      },
      {
      &quot;f_name&quot;:&quot;eleni&quot;,
      &quot;l_name&quot;:&quot;kot&quot;, 
      &quot;age&quot;: 27,
      }
  ]
  </code></pre>
  <p>I want to insert for every user a history array and within that array another array. I use the following JSON code but I get an error.</p>
  <pre><code>db.patientdata.insertOne({f_name:&quot;Raf&quot;},{$set: {history:[&quot;desease&quot;:&quot;fever&quot;,&quot;treatment&quot;:&quot;ponstan&quot;]}})
  </code></pre>
  <p><a href="https://i.stack.imgur.com/qtZdG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qtZdG.png" alt="enter image description here" /></a></p>
  <p>Do I have to &quot;$set&quot; the 2nd array as well?</p>
  <p>Thank you in advance.</p>
  <p><strong>edit after further meddling with this:</strong></p>
  <p>I also tired the following JSON code:</p>
  <pre><code>db.patientdata.updateOne({f_name:&quot;Raf&quot;},{$set: {&quot;history&quot;:[&quot;desease&quot;,&quot;treatment&quot;]}})
  db.patientdata.updateOne({f_name:&quot;Raf&quot;},{$set: {&quot;desease&quot;:[&quot;fever&quot;]}})
  db.patientdata.updateOne({f_name:&quot;Raf&quot;},{$set: {&quot;treatment&quot;:[&quot;ponstan&quot;]}})
  </code></pre>
  <p>but I there wasn't a second embedded array within the first one:
  <a href="https://i.stack.imgur.com/UBx0f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UBx0f.png" alt="enter image description here" /></a></p>