title: MongoDB update complex document
body: <p>I search for some similar example, but didn't find something good.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{
      "_id" : ObjectId("571dea148234534308a290e"),
      "user" : "myusername",
      "duration" : "",
      "test_details" : [ 
          {
              "test" : "New",
              "test_id" : "0",
              "comments" : "will be some text",
              "text" : ""
          }, 
          {
              "test" : "**to change value here**",
              "test_id" : "1",
              "comments" : "will be some text",
              "text" : "**to change value here**"
          }, 
          {
              "test" : "New",
              "test_id" : "2",
              "comments" : "will be some text",
              "text" : ""
          }, 
          {
              "test" : "New",
              "test_id" : "3",
              "comments" : "will be some text",
              "text" : ""
              "sub_test_details" : [ 
                  {
                      "56eed334534566ac5668ca18" : [ 
                          {
                              "sub_test" : "New",
                              "sub_test_id" : "0",
                              "sub_comments" : "will be some text",
                              "sub_text" : ""
                          }, 
                          {
                              "sub_test" : "New",
                              "sub_test_id" : "1",
                              "sub_comments" : "will be some text",
                              "sub_text" : ""
                          }, 
                          {
                              "sub_test" : "New",
                              "sub_test_id" : "2",
                              "sub_comments" : "will be some text",
                              "sub_text" : ""
                          }
                      ]
                  }, 
                  {
                      "56eed3b1f37d66ac5668ca19" : [ 
                          {
                              "sub_test" : "New",
                              "sub_test_id" : "0",
                              "sub_comments" : "will be some text",
                              "sub_text" : ""
                          }, 
                          {
                              "sub_test" : "New",
                              "sub_test_id" : "1",
                              "sub_comments" : "will be some text",
                              "sub_text" : ""
                          }, 
                          {
                              "sub_test" : "**to change value here**",
                              "sub_test_id" : "2",
                              "sub_comments" : "will be some text",
                              "sub_text" : "**to change value here**"
                          }
                      ]
                  } 
              ]
          }, 
          {
              "test" : "New",
              "test_id" : "4",
              "comments" : "will be some text",
              "text" : ""
          }
      ],
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>And the questions are:</p>
  
  <ol>
  <li><p>What is query to update text="Completed Successfully" and test="Done" where _id" : ObjectId("571dea148234534308a290e").test_id=1.</p></li>
  <li><p>What is query to update sub_text="Sub Completed Successfully" and sub_test="Sub Done" where _id" : ObjectId("571dea148234534308a290e").test_details.test_id=3.sub_test_details.56eed3b1f37d66ac5668ca19.sub_step_id=2</p></li>
  </ol>
  
  <p>In my case i will get <strong>id</strong>, <strong>test_id</strong>, <strong>exam_num(56eed3b1f37d66ac5668ca19)</strong>, <strong>sub_test_id</strong> will be parameters to find relevant place for updating.
  An array elements size not always constant. Therefore I use id to specify exactly which element I am looking for.</p>
  
  <p>Thanks</p>