简体   繁体   中英

How to fetch more than 100 records from azure cosmos db using query

I want to fetch more than 100 records from azure-cosmos DB using select query.

I am writing a stored procedure and using a select query to fetch the record.

SELECT * FROM activities a

I am getting only 100 records though there are more than 500 records. I am able to get all records usings the setting configuration provided by Azure.

在此输入图像描述

I want to perform the same operation using query or stored procedure. How can I do that ??

Please suggest changes that need to accomplish.

I am writing a stored procedure and using a select query to fetch the record.

SELECT * FROM activities a

I am getting only 100 records though there are more than 500 records.

The default value of FeedOptions pageSize property for queryDocuments is 100, which might be the cause of the issue. Please try to set the value to -1 . The following stored procedure works fine on my side, please refer to it.

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));
    }
  );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM