title: Error when trying to update MongoDb array element
body: <p>In my Azure CosmosDb MongoApi I have JSON with an embed array of documents.</p>
  
  <pre><code>{
      "_id": ObjectId("5a95745df886842904b82f71"),
      "token": "value1",
      "channel": "value2",
      "urls":
      [
          {
              "url": "&lt;url1&gt;", 
              "interval": "&lt;int&gt;"
          },
          {
              "url": "&lt;url2&gt;"
              "interval": "&lt;int&gt;"
          }
      ]
  }
  </code></pre>
  
  <p>I want to update "interval" field in a specific array element. Problem is when I use solutions like <a href="https://stackoverflow.com/questions/31453681/mongo-update-array-element-net-driver-2-0">this</a> or <a href="https://stackoverflow.com/questions/10522347/mongodb-update-objects-in-a-documents-array-nested-updating">this</a>, I end up with an exception:</p>
  
  <pre><code>MongoDB.Driver.MongoCommandException: Command findAndModify failed: Invalid BSON field name 'urls.$.interval'.
  </code></pre>
  
  <p>So, I decided to try running queries in Mongo Shell and got the same error:</p>
  
  <pre><code>{
      "nMatched": 0,
      "nUpserted": 0,
      "nModified": 0,
      "writeError": 
      {
          "code": 2,
          "errmsg": "Invalid BSON field name 'urls.$.interval'"
      }
  }
  </code></pre>
  
  <p>Here is my C# code:</p>
  
  <pre><code>    var filterBuilder = Builders&lt;User&gt;.Filter;
      var filter = filterBuilder.Where(p =&gt; p.Token == model.Token &amp;&amp; p.Channel == model.Channel &amp;&amp; p.Urls.Any( u =&gt; u.Url == model.Url));
      var update = Builders&lt;User&gt;.Update.Set(p =&gt; p.Urls.ElementAt(-1).interval, 5);
      await _context.Users.FindOneAndUpdateAsync&lt;User&gt;(filter, update);
  </code></pre>
  
  <p>Here is my MongoDb shell request:</p>
  
  <pre><code>db.Users.update( {"urls.interval": 60}, {$set: {"urls.$.interval": 30}} ); 
  </code></pre>
  
  <p>My question is what is causing this exception and how can I avoid it?</p>