简体   繁体   English

如何使用查询从azure cosmos db中获取超过100条记录

[英]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. 我想使用select query从azure-cosmos DB中获取100多条记录。

I am writing a stored procedure and using a select query to fetch the record. 我正在编写存储过程并使用select查询来获取记录。

SELECT * FROM activities a

I am getting only 100 records though there are more than 500 records. 虽然有超过500条记录,但我只获得了100条记录。 I am able to get all records usings the setting configuration provided by Azure. 我可以使用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查询来获取记录。

SELECT * FROM activities a SELECT * FROM活动a

I am getting only 100 records though there are more than 500 records. 虽然有超过500条记录,但我只获得了100条记录。

The default value of FeedOptions pageSize property for queryDocuments is 100, which might be the cause of the issue. FeedOptions的默认值的pageSize属性queryDocuments是100,这可能是问题的原因。 Please try to set the value to -1 . 请尝试将值设置为-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));
    }
  );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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