title: How to update value of specific embedded document, inside an array, of a specific document in MongoDB?
body: <p>I have the following structure in my document: </p>
  
  <pre><code>{
    _id : ObjectId("43jh4j343j4j"), 
    array : [
              { 
                _arrayId : ObjectId("dsd87dsa9d87s9d7"),
                someField : "something",
                someField2 : "something2"
              },
              { 
                _arrayId : ObjectId("sds9a0d9da0d9sa0"),
                someField : "somethingElse",
                someField2 : "somethingElse2"
              }
     ]
   }
  </code></pre>
  
  <p>I want to update <strong>someField</strong> and <strong>someField2</strong> but only for one of the items in the array, the one that matches <strong>_arrayId</strong> (e.g. <code>_arrayId : ObjectId("dsd87dsa9d87s9d7")</code>; and only for this document (e.g. <code>_id : ObjectId("43jh4j343j4j")</code> ) and no other. </p>
  
  <p>The <strong>arrayIds</strong> are not unique to the document that's why I need it to be for a specific document. I could use the <code>$ positional operator</code> if I wanted to update that value within the array for every document it exists in, but that's not what I want. </p>
  
  <p>I am trying to accomplish this in <a href="/questions/tagged/java" class="post-tag" title="show questions tagged 'java'" rel="tag">java</a> but a command line solution would work as well. </p>