pagination

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pagination

type Pagination paginations.Pagination

Pagination defines the query limits and offsets. It defines the maximum size (Limit) as well as an offset at which the query should start.

func New

func New(a, b int, tp Type) *Pagination

New creates new pagination for the given query The arguments 'a' and 'b' means as follows: - 'limit' and 'offset' for the type 'TpLimitOffset' - 'pageSize' and 'pageNumber' for the type 'TpPage'

func NewLimitOffset

func NewLimitOffset(limit, offset int) *Pagination

NewLimitOffset createw new limit, offset type pagination

func NewPaged

func NewPaged(number, size int) *Pagination

NewPaged creates new paged type Pagination

func (*Pagination) Check

func (p *Pagination) Check() error

Check checks if the pagination is well formed

func (*Pagination) FormatQuery

func (p *Pagination) FormatQuery(q ...url.Values) url.Values

FormatQuery formats the pagination for the url query.

func (*Pagination) GetLimitOffset

func (p *Pagination) GetLimitOffset() (int, int)

GetLimitOffset gets the limit and offset from the current pagination

func (*Pagination) String

func (p *Pagination) String() string

String implements Stringer interface

func (*Pagination) Type

func (p *Pagination) Type() Type

Type returns pagination type

type Type

type Type int

Type defines the pagination type

const (
	// TpLimitOffset is the pagination type that defines limit or (and) offset
	TpLimitOffset Type = iota

	// TpPage is the pagination type that uses page type pagination i.e. page=1 page size = 10
	TpPage

	// TpCursor is the current cursor pagination type
	TpCursor
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL