title: How can I update a property of an object that is contained in an array of a parent object using mongodb?
body: <p>I'm using MongoDB to be my database. i have a data:</p>
  
  <pre class="lang-js prettyprint-override"><code> {
     _id : '123'
     friends: [
       {name: 'allen', emails: [{email: '11111', using: 'true'}]}
     ]
   }
  </code></pre>
  <p>now, i wanna to modify user's friends' emails ' email,  whose _id is '123'
  i write like this:</p>
  <pre class="lang-js prettyprint-override"><code>db.users.update ({_id: '123'}, {$set: {&quot;friends.0.emails.$.email&quot; : '2222'} })
  </code></pre>
  <p>it's easy, but , it's wrong , when the emails array has two or more data.
  so, my question is:
  how can i modify  the data in a nested filed --- just have two or more nested array? Thanks.</p>