title: Update an array of strings nested within an array of objects in mongodb
body: <p>I want to update an array of strings which is nested inside an array of Objects.</p>
  
  <p>This is my Mongo document:</p>
  
  <pre><code>{
      "_id" : ObjectId("5a52d995734d1d388d17eb0b"),
      "teams" : [ 
          {
              "assignedModels" : [ 
                  "5a1665a82c7eb90001a7d676", 
                  "58d8fc2d734d1d5af6dd4803"
              ]
          }, 
          {
              "assignedModels" : [ 
                  "58d8fc2d734d1d5af6dd4803"
              ]
          }
      ]
  }
  </code></pre>
  
  <p>Now i want to remove <strong><em>"58d8fc2d734d1d5af6dd4803"</em></strong> string from the assignedModels of each team object.</p>
  
  <p>I have already tried some queries, but nothing is working as i expected</p>
  
  <p><strong>Current query:</strong></p>
  
  <pre><code>db.collection('organisations').updateMany(
      { _id: database.ObjectID("5a52d995734d1d388d17eb0b") ,'teams.assignedModels' : { $exists:true } },
      { $pull : {'teams.$.assignedModels' : "58d8fc2d734d1d5af6dd4803" } },
      { multi: true });
  </code></pre>
  
  <p><strong>Current output:</strong></p>
  
  <p>updated the 0th element of the teams array correctly but does not traverse through the other objects.</p>
  
  <p>i tried <strong><em>$[], teams.assignedModels</em></strong>  as well  </p>
  
  <p><strong>Expected output:</strong></p>
  
  <pre><code>{
      "_id" : ObjectId("5a52d995734d1d388d17eb0b"),
      "teams" : [ 
          {
              "assignedModels" : [ 
                  "5a1665a82c7eb90001a7d676"
              ]
          }, 
          {
              "assignedModels" : [ 
              ]
          }
      ]
  }
  </code></pre>