title: How to use MongoDB 3.6 position operator to pull value from multiple items in array
body: <p>I have an array like this:</p>
  
  <pre><code>{
      "_id" : ObjectId("5ae5afc93e1d0d2965a4f2d7"),
      "entries" : [ 
          {
              "_id" : ObjectId("5b159ebb0ed51064925dff24"),
              "tags" : [ 
                  ObjectId("5b142608e419614016b89925"), 
                  ObjectId("5b142b40e419614016b89937")
              ]
          }
      ],
      "tags" : [ 
          {
              "_id" : ObjectId("5b142608e419614016b89925"),
              "name" : "Outdated",
              "color" : "#3498db"
          }, 
          {
              "_id" : ObjectId("5b142b40e419614016b89937"),
              "name" : "Todo",
              "color" : "#e8b00a"
          }
      ],
  }
  </code></pre>
  
  <p>I would like to remove "tagId2" from every item in <code>entries</code>. I'm trying to use the <a href="https://docs.mongodb.com/manual/reference/operator/update/positional-all/#up._S_[]" rel="nofollow noreferrer">position operator</a> for this which is supposed to <a href="https://docs.mongodb.com/manual/reference/operator/update/positional-all/#update-all-documents-in-an-array" rel="nofollow noreferrer">work with arrays</a>:</p>
  
  <pre><code>db.projects.updateOne(
  {
    "_id" : ObjectId("5ae5afc93e1d0d2965a4f2d7"),
  },
  {
    $pull: {
      'entries.$[].tags': ObjectId("5b142b40e419614016b89937")
    }
  })
  </code></pre>
  
  <p>But I get a MongoDB error:</p>
  
  <blockquote>
    <p>WriteError: cannot use the part (entries of entries.$[].tags) to traverse the element ([the entries array])</p>
  </blockquote>
  
  <p>How do I use it correctly? Thanks.</p>