title: DocumentDb stored procudure collection.queryDocuments not working
body: <p>I am developping a system for large data scale. Currently, I am testing stored procedure in collection with less than 300k documents.</p>
  
  <p>I am following this example:
  <a href="https://azure.microsoft.com/en-gb/documentation/articles/documentdb-programming/" rel="nofollow">DocumentDB server-side programming: Stored procedures, database triggers, and UDFs</a></p>
  
  <p>"createDocument" and "replaceDocument" are working fine so far. 
  But queryDocuments is not working at all no matter how many ways i tried. I tried to put throw exception in many place but throw exception inside callBack are not getting hit at all.</p>
  
  <p>Have anyone used queryDocuments() in stored procedure successfully?</p>
  
  <pre><code>function MoveTree(nodeJson, targetParentNodeJson) {
  var node = JSON.parse(nodeJson);
  var targetParentNode = JSON.parse(targetParentNodeJson);
  
  var collection = getContext().getCollection();
  var collectionLink = collection.getSelfLink();
  
  var count = 0;
  
  //&lt;==Tried put throw exception here and it is hit
  var node;
  var IsAccept = collection.queryDocuments(
      collection.getSelfLink(),
      'SELECT * FROM Nodes p where p.id  = "' + nodeId + '"',
      function (err, documents, responseOptions) {
          //&lt;==Tried put throw exception here but it is not hit
          if (err) throw new Error(err);
          if (!documents || documents.length != 1) throw new Error("Unable to find node.");
          node = documents[0];
          //&lt;==Tried put throw exception here but it is not hit
      });
  //&lt;==Tried put throw exception here and it is hit
  </code></pre>
  
  <p>//...
  }</p>
  
  <p><a href="http://i.stack.imgur.com/spDPn.jpg" rel="nofollow">Screenshot of code with comments</a></p>