title: How to fetch All records from azure cosmos db using query
body: <p>I want to fetch more than 100 records from azure-cosmos DB using select query.</p>
  
  <p>I am writing a stored procedure and using a select query to fetch the record.</p>
  
  <p>This is my stored procedure - </p>
  
  <pre><code>function getall(){
   var context = getContext();
    var response = context.getResponse();
    var collection = context.getCollection();
    var collectionLink = collection.getSelfLink();
  
    var filterQuery = 'SELECT * FROM c';
  
    collection.queryDocuments(collectionLink, filterQuery, {pageSize:-1 },
      function(err, documents) {
        response.setBody(response.getBody() + JSON.stringify(documents));
      }
    );
  }
  </code></pre>
  
  <p>Initially, It was working with less amount of data in database.</p>
  
  <p>But, with large amount of data,
     The stored procedure is throwing this exception - </p>
  
  <blockquote>
    <p>Encountered exception while executing function. Exception = Error:
    Resulting message would be too large because of "Body". Return from
    script with current message and use continuation token to call the
    script again or modify your script. Stack trace: Error: Resulting
    message would be too large because of "Body". Return from script with
    current message and use continuation token to call the script again or
    modify your script.</p>
  </blockquote>