title: bulk update by Stored procedures of complex type cosmosDB azure
body: <p>I try to update bulk of complex documents in cosomosdb via stored procedures in server side.
  My client side is developed in C#.</p>
  
  <p>I want to implement stored procedure, that update the details of course to list of students, I want to update the course details for all students that belong to list of <strong>ids</strong> with given <strong>courseDetiels</strong></p>
  
  <ol>
  <li>How I create query that return all the document with id that contain in the ids parameter.</li>
  </ol>
  
  <p>2.How I can update complex-object for example:</p>
  
  <pre><code>   public class CourseDetiels : Microsoft.Azure.Documents.Resource
  {
      [JsonProperty("name")]
      public String CName { get; set; }
  
      [JsonProperty("finalGrade")]
      public double FinalGrade{ get; set; }
      [JsonProperty("GradesInWorks")]
      public double[] GradesInWorks{ get; set; }
  </code></pre>
  
  <p>}</p>
  
  <p>I need to update the only the courses that taken by the user in specific semester in Courses dictionary in Student class:</p>
  
  <pre><code>    public class Student: Microsoft.Azure.Documents.Resource
  {
      [JsonProperty(PropertyName = "id")]
      public String ID { get; set; }
      [JsonProperty(PropertyName = "Courses")]
      public Dictionary&lt;string, CourseDetiels&gt; Courses{ get; set; }
  
  }
  </code></pre>
  
  <p>This is the pseudo code I want to write....</p>
  
  <pre><code>function UpdateCourses(ids,courseDetiels) {
  
     var collection = getContext().getCollection();
     var collectionLink = collection.getSelfLink();
     var response = getContext().getResponse();
     var docCount = 0;
     var counter = 0;
  
     UpdateCoursesByIds(ids,complexObject);
  
     function UpdateCoursesByIds(ids,complexObject,continuation) {
          var query = {
              query: "select * from root c where ...." **//how to select only documents that contains in ids??**
          };
  
          var requestOptions = {
              continuation: continuation
          };
  
          var isAccepted =
              collection
              .queryDocuments(collectionLink,
                              query,
                              requestOptions,
                              function queryCallback(err, documents, responseOptions) {
                                       if (err) throw err;
                                       if (documents.length &gt; 0) {
                                          // If at least one document is found, update it.
                                          docCount = documents.length;
                                          for (var i=0; i&lt;docCount; i++){
                                              UpdateDoc(documents[i]);
                                          }
                                          response.setBody("Updated " + docCount + " documents");
                                        }
                                        else if (responseOptions.continuation) {
                                          UpdateCoursesByIds(responseOptions.continuation);
                                        } else {
                                               throw new Error("Document not found.");
                                               }
                              });
  
          if (!isAccepted) {
              throw new Error("The stored procedure timed out");
          }
      }
  
      function UpdateDoc(document) {
          //Optimistic concurrency control via HTTP ETag.
          var requestOptions = { etag: document._etag };
  
          **//I NEED TO UPDATE ONLY THE COURSES THAT TAKEN ....**
  
          var isAccepted = collection
                           .replaceDocument(document._self,
                                            document,
                                            requestOptions,
                                            function replaceCallback(err, updatedDocument, responseOptions) {
                                                     if (err) throw err;
                                                     counter++;
                                             });
  
          // If we hit execution bounds - throw an exception.
          if (!isAccepted) {
              throw new Error("The stored procedure timed out");
          }
      }
  }
  </code></pre>
  
  <p>Thanks.</p>