Documentation
¶
Overview ¶
This package is for pagination
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLimitOffset ¶ added in v0.3.0
GetLimitOffset calculates the limit and offset for pagination based on the given page and pageSize. It returns the offset, which is the number of records to skip, and the limit, which is the number of records to return. The offset is calculated as (page - 1) * pageSize, and the limit is set to pageSize.
func GetPageAndPageSize ¶
GetPageAndPageSize validates the input page and pageSize and returns optimized values. If the page value is less than or equal to zero, it defaults to 'defaultPage'. If pageSize exceeds 'maxPageSize', it is set to 'maxPageSize'. This allows pageSize to be less than or equal to zero, accommodating APIs that use list API as a "ping" endpoint. Returns: Optimized 'page' and 'pageSize'.
func GetTotalPage ¶
GetTotalPage calculates the total number of pages needed to display all records. It takes the total number of records and the desired page size as input. The output is the minimum number of pages required to display all records, given that each page displays at most 'pageSize' records.