Documentation ¶
Index ¶
- type Options
- type PaginatedResults
- type Pagination
- func (p *Pagination) HasNext() bool
- func (p *Pagination) HasPrevious() bool
- func (p *Pagination) Next() int
- func (p *Pagination) Offset() int
- func (p *Pagination) Page() int
- func (p *Pagination) Pages() int
- func (p *Pagination) PerPage() int
- func (p *Pagination) Previous() int
- func (p *Pagination) SetNext(next int)
- func (p *Pagination) SetOffset(offset int)
- func (p *Pagination) SetPage(page int)
- func (p *Pagination) SetPages(pages int)
- func (p *Pagination) SetPerPage(perPage int)
- func (p *Pagination) SetPrevious(previous int)
- func (p *Pagination) SetTotal(total int)
- func (p *Pagination) Total() int
- type PaginationResponse
- type Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { Limit int `json:"limit" db:"limit" url:"limit"` // the number of items Page int `json:"page" db:"page" url:"limit"` // the page }
pagination options
type PaginatedResults ¶
type PaginatedResults struct { Data []interface{} `json:"data" db:"data"` Page int `json:"page" db:"page"` Limit int `json:"limit" db:"limit"` Total int `json:"total" db:"total"` }
PaginatedResults - paginated results
type Pagination ¶
type Pagination struct {
// contains filtered or unexported fields
}
Pagination represents a pagination.
func New ¶
func New(page, perPage, total int) *Pagination
New creates a new pagination. @param page is the current page. @param perPage is the number of items per page. @param total - is the total number of items. @return *Pagination
func (*Pagination) HasNext ¶
func (p *Pagination) HasNext() bool
HasNext returns true if the pagination has a next page, false otherwise. @return bool
func (*Pagination) HasPrevious ¶
func (p *Pagination) HasPrevious() bool
HasPrevious returns true if the pagination has a previous page, false otherwise. @return bool
func (*Pagination) Offset ¶
func (p *Pagination) Offset() int
Offset returns the offset. @return int
func (*Pagination) Pages ¶
func (p *Pagination) Pages() int
Pages returns the total number of pages. @return int
func (*Pagination) PerPage ¶
func (p *Pagination) PerPage() int
PerPage returns the perPage. @return int
func (*Pagination) Previous ¶
func (p *Pagination) Previous() int
Previous returns the previous. @return int
func (*Pagination) SetNext ¶
func (p *Pagination) SetNext(next int)
set the next @param next - the next page. @return void
func (*Pagination) SetOffset ¶
func (p *Pagination) SetOffset(offset int)
set the offset @param offset - the offset. @return void
func (*Pagination) SetPage ¶
func (p *Pagination) SetPage(page int)
set the page @param page - the current page. @return void
func (*Pagination) SetPages ¶
func (p *Pagination) SetPages(pages int)
set the pages @param pages - the total number of pages.
func (*Pagination) SetPerPage ¶
func (p *Pagination) SetPerPage(perPage int)
set the perPage @param perPage - the number of items per page. @return void
func (*Pagination) SetPrevious ¶
func (p *Pagination) SetPrevious(previous int)
set the previous @param previous - the previous page. @return void
func (*Pagination) SetTotal ¶
func (p *Pagination) SetTotal(total int)
set the total @param total - the total number of items. @return void
type PaginationResponse ¶
type PaginationResponse struct { Offset int `json:"offset" db:"offset"` // where to start from Limit int `json:"limit" db:"limit"` // the number of items Total int `json:"total" total:"total"` // total number of items CurrentPage int `json:"page" db:"page"` // the current page }
PaginationResponse - pagination