title: Update Matched Object In Array
body: <p>I am trying to update nested values in a MongoDB document but I get the following error : 
  "cannot use the part (Accounts of Accounts.Rules.Frequency) to traverse the element"</p>
  
  <p>Below is the structure of my document and the code I am trying to run :</p>
  
  <pre><code>{"_id" : ObjectId("5ab2313bf7951607c1072e54"),
   "Customer_id" : 2,
   "Accounts" : 
    [ {"Account_id" : NumberLong(1398868310133024),
      "AccountType" : "admin",
      "Created_at" : "01-01-2018",
      "Rules" : {"Goal" : 200,
                 "DoNotDisturbFrom" : "22",
                 "DoNotDisturbTo" : "8",
                 "Frequency" : "weekly"}
      }, 
     {"Account_id" : 2,
      "AccountType" : "user",
      "Created_at" : "01-02-2018",
      "Rules" : {"Goal" : 200,
                 "DoNotDisturbFrom" : "20",
                 "DoNotDisturbTo" : "12",
                 "Frequency" : "monthly"}
      }
   ]
  }
  </code></pre>
  
  <p>Here is the code : </p>
  
  <pre><code>result = collection.update_one({"Accounts.Account_id":1398868310133024}, {'$set':{"Accounts.Rules.Frequency":"monthly"}})
  print result
  </code></pre>