ardalis / Result

A result abstraction that can be mapped to HTTP response codes if needed.
MIT License
866 stars 107 forks source link

Add next page token to PagedResult #82

Open danielEsmart opened 2 years ago

danielEsmart commented 2 years ago

In many cases a token for the next page is used, but neither PagedResult or PagedInfo includes this. This could be solved by adding a string property to either PagedResult or PagedInfo.

I'm glad to do a PR with proposed changes.

ardalis commented 2 years ago

Why would it be a string property? How is the token used?

I'm open to the addition, just not sure of how one would use it when working with paged data.

danielEsmart commented 2 years ago

Thanks for the reply.

Use cases:

Utilizing the paging function on supported databases. To prevent the database from having to count the total amount of records returned from the query for each request. Avoid the need for counting and keeping track of pages or records. Just use the token until the token is null (end of list). Example: We query a database api that supports continuation token for a list of records, but only 1000 at a time. Then we receive a list of records and a continuation token in a header. We then use that token to get the next 1000 in the next request to the api. Repeat that until the token is null, and we have received all the records.

This is espescially useful when dealing with document db that has a limit of 1000 records on searches.

Token Example: +RID:~zZsJALuJciTIbQkAAAAAAA==#RT:1#TRC:10#RTD:kmuM5aCUfQC/Ixfyqz/MBMHZTyOg#ISV:2#IEO:65551#FPC:AgEAJQAaAAI4AOToKBEAwP2CQKHcm39yAoD/8QPRAngADAgAEScA+OFA/x8NEADxHwDAIUABAOEFAP4RQB8ADiIAcS0GAEyAUw3APzLE/wc+gRCA34AxAAADUQAYIBeAgQH4Dw8gADEA4AcRBZwDfoNIhkEBAPARQP8AMQAA3hFABwCRAgDAERYAoRwDABEFAPwhQH8Av4DRDADAcUD/ABIuALIEAPj/Ae+eAcAPAPECAAbBABgAbYWWgB2ADYDhA/D/EUAPAG+B8QLwAMEBgAETBgDSIwD8CwAUCAAhEADAEUD/AxU0AAErAPwhQA8AMQCA/yFAAQAhAPj/EUD/H6IEAN4HAMELAP5hQP9ZHIAhAMD/YUD/B3EAwP8WogDQAMBAwQAA/sBAFYAxBAD+wUABAL+A0kN///sBwQAA/8BAIQDA/xJBHwD8/7FAAwAiAQD//wOxAAD8EUD/DxEAAMBBQAMAsQEA/hFA/wdBA/j/EUD/HxE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