Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRequest ¶
AddRequest adds pagination to the gorm transaction based on the given request.
transaction: The GORM database transaction. request: The request object containing pagination information.
- PageIndex: The index of the page to retrieve (starting from 0).
- PageSize: The number of records to retrieve per page.
Returns the modified transaction with the pagination applied.
func NewPagingError ¶
Types ¶
type PagingSettingsInterface ¶
type PagingSettingsInterface interface {
GetPagingDefault() (pageSize int)
}
type Request ¶
func ValidateAndApplyPagingRules ¶
func ValidateAndApplyPagingRules(model PagingSettingsInterface, request *Request) (*Request, error)
ValidateAndApplyPagingRules performs a validation of the original request and adds correct the correct values (defaults) if needed
type Response ¶
type Response struct {
PageIndex int `json:"index" binding:"required"`
PageSize int `json:"size" binding:"required"`
TotalDisplayableResults uint64 `json:"totalDisplayableResults" binding:"required"`
TotalResults uint64 `json:"totalResults,omitempty"`
}
Response represents a response object containing information about pagination and total count of records.
- PageIndex: The index of the page (starting from 0). This is required.
- PageSize: The number of records per page. This is required.
- TotalDisplayableResults: The total number of results that can be paginated. Due to database restrictions, in case of large number of results, some of the results cannot be retrieved. In such cases, this number will be lower than the `TotalResults`. This is required.
- TotalResults: The total count of results as it exists in database, including those that may not be retrieved. This is optional and must not be set if the value does not differ from `TotalDisplayableResults`
func NewResponse ¶
func NewResponseWithTotalResults ¶ added in v1.8.0
Click to show internal directories.
Click to hide internal directories.
