title: How do I update nested MongoDB object
body: <p>I have been stuck on this for 6 hours now... How do I update a field inside an object inside and element that is inside another object in MongoDB.</p>
  <p>So I have a collection of users, each user is one document which contains arrays of objects. These objects have fields that i want to be able to change. Like i want to change just the &quot;frequency&quot; and &quot;status&quot; field but i want to change only the one with an &quot;_id&quot; equal to a query.</p>
  <p>I've tried</p>
  <pre><code>db.collections.users.updateOne(
    {},
    {$set: {&quot;nouns.$[element].status&quot;: 3}},
    {multi: true,
    arrayFilters: [{&quot;element._id&quot;: req.body.inputId}]}
  );
  </code></pre>
  <p>Plus a lot of other things.</p>
  <pre><code>{
  &quot;_id&quot; : ObjectId(&quot;5f7d8490c1842471c6bcea42&quot;),
  &quot;username&quot; : &quot;eric@mail.com&quot;,
  &quot;nouns&quot; : [ 
      {
          &quot;_id&quot; : ObjectId(&quot;5f7d849cc1842471c6bcea43&quot;),
          &quot;word&quot; : &quot;die Sonne&quot;,
          &quot;timeStamp&quot; : ISODate(&quot;2020-10-07T09:04:28.436Z&quot;),
          &quot;frequency&quot; : 0,
          &quot;status&quot; : 0
      }, 
      {
          &quot;_id&quot; : ObjectId(&quot;5f7d84a8c1842471c6bcea45&quot;),
          &quot;word&quot; : &quot;das Wetter&quot;,
          &quot;timeStamp&quot; : ISODate(&quot;2020-10-07T09:04:40.940Z&quot;),
          &quot;frequency&quot; : 0,
          &quot;status&quot; : 0
      }, 
      {
          &quot;_id&quot; : ObjectId(&quot;5f7d84afc1842471c6bcea47&quot;),
          &quot;word&quot; : &quot;der Apfel&quot;,
          &quot;timeStamp&quot; : ISODate(&quot;2020-10-07T09:04:47.403Z&quot;),
          &quot;frequency&quot; : 0,
          &quot;status&quot; : 0
      }, 
      {
          &quot;_id&quot; : ObjectId(&quot;5f7d84b9c1842471c6bcea49&quot;),
          &quot;word&quot; : &quot;das Maedchen&quot;,
          &quot;timeStamp&quot; : ISODate(&quot;2020-10-07T09:04:57.388Z&quot;),
          &quot;frequency&quot; : 0,
          &quot;status&quot; : 0
      }, 
      {
          &quot;_id&quot; : ObjectId(&quot;5f7d84c8c1842471c6bcea4b&quot;),
          &quot;word&quot; : &quot;das Auto&quot;,
          &quot;timeStamp&quot; : ISODate(&quot;2020-10-07T09:05:12.036Z&quot;),
          &quot;frequency&quot; : 0,
          &quot;status&quot; : 0
      }
  ],
  &quot;verbs&quot; : [],
  &quot;adjectives&quot; : [],
  &quot;others&quot; : [],
  &quot;salt&quot; : &quot;*****&quot;,
  &quot;hash&quot; : &quot;*****&quot;,
  &quot;__v&quot; : 5
  }
  </code></pre>