title: Update embedded mongoose document in array
body: <p>Lets say that I have the following document in the books collection:</p>
  
  
  
  <pre class="lang-javascript prettyprint-override"><code>{
    _id:0 ,
    item: "TBD",
    stock: 0,
    info: { publisher: "1111", pages: 430 },
    tags: [ "technology", "computer" ],
    ratings: [ { _id:id1, by: "ijk", rating: 4 }, {_id:id2 by: "lmn", rating: 5 } ],
    reorder: false
  }
  </code></pre>
  
  <p>I would like to update the value of <code>ratings[k].rating</code> and all I know is the id of the collection and the _id of the objects existing in the array ratings. </p>
  
  <p>The tutorial of mongoDB has the following example that uses the position of the object inside the array but I suppose that if the update can only be done by knowing the position, this means that I firstly have to find the position and then proceed with the update? Can I do the update with only one call and if so how I can do that? </p>
  
  <pre class="lang-javascript prettyprint-override"><code>db.books.update(    
     { _id: 1 },
     {
       $inc: { stock: 5 },
       $set: {
         item: "ABC123",
         "info.publisher": "2222",
         tags: [ "software" ],
         "ratings.1": { by: "xyz", rating: 3 }
       }
     }
  )
  </code></pre>