Closed yingting2017 closed 6 years ago
Hi @yingting2017 , I am little unclear on the question. Are you asking which method we would recommend for your use case? The second method would be faster and consume lesser RUs on the whole.
I am closing this as the initial query has been addressed. Please feel free to reopen it if you have any followup. Thanks!
Use-Case: Let’s say user wants to access 10 records starting from 100th index (order by query may change based on timestamp, city or name etc.).
So, one way is to set the page size as 10 (this can any fixed number) and then make a call to the queryDocuments(collectionLink, sqlQuery, feedOptions) API. In the response of this API, we get the FeedResponse and using fetchNextBlock() API of FeedResponseI just need to jump to the 100th index in 10 iterations (in our case) and in turn return the next desired block to the user. The problem with this approach is to iterate the records multiple times which I don’t want as this nth index can be any big number.
The other way is to set the page size 100 (staring index given by user) and then make a call to the queryDocuments(collectionLink, sqlQuery, feedOptions). In the response of this API, we get the FeedResponse and using the get ContinuationToken() API of FeedResponse, I get the token. I’ll use this token to construct the FeedOptions again and then pass it to queryDocuments(collectionLink, sqlQuery, feedOptions) API to get the final results.