SLN
SLN

Reputation: 5092

Where is MaxItemCount for cosmos DB pagination for Python azure SDK

having searching quite while and haven't found the MaxItemCount for cosmos DB pagination in python azure SDK from the official web site and the code sample

The REST-api is written by FastAPI framework, use Azure cosmos DB as the storage, pagination hasn't been implemented. The cosmos sdk I'm using is version 3.1.2

query = {"query": "SELECT * FROM aac104 ORDER BY aac104.entryTimestamp ASC"}                    
for item_dict in client.QueryItems(self.clink, query, options={"enableCrossPartitionQuery": True}):   
    yield self._parse_entry(item_dict) 

                                                           

Can someone help me with how to use MaxItemCount to get the pagination function on in Python Azure SDK?

Upvotes: 0

Views: 423

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136356

For SDK version 3.x (that you're using), please try by definining maxItemCount in the query options. Your code would be something like:

query = {"query": "SELECT * FROM aac104 ORDER BY aac104.entryTimestamp ASC"}                    
for item_dict in client.QueryItems(self.clink, query, options={"enableCrossPartitionQuery": True; "maxItemCount": 10;}):   
    yield self._parse_entry(item_dict) 

Upvotes: 1

Related Questions