Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
func (Filter) SortColumn ¶
Check that the client-provided Sort field matches one of the entries in our safelist and if it does, extract the column name from the Sort field by stripping the leading hyphen character (if one exists).
func (Filter) SortDirection ¶
Return the sort direction ("ASC" or "DESC") depending on the prefix character of the Sort field.
type Metadata ¶
type Metadata struct { CurrentPage int `json:"current_page,omitempty"` PageSize int `json:"page_size,omitempty"` FirstPage int `json:"first_page,omitempty"` LastPage int `json:"last_page,omitempty"` TotalRecords int `json:"total_records,omitempty"` }
Define a new Metadata struct for holding the pagination metadata.
func CalculateMetadata ¶
The calculateMetadata() function calculates the appropriate pagination metadata values given the total number of records, current page, and page size values. Note that the last page value is calculated using the math.Ceil() function, which rounds up a float to the nearest integer. So, for example, if there were 12 records in total and a page size of 5, the last page value would be math.Ceil(12/5) = 3.