paginations

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: Apache-2.0 Imports: 4 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 struct {
	// contains filtered or unexported fields
}

Pagination is a struct that keeps variables used to paginate the result.

func NewLimitOffset added in v0.2.1

func NewLimitOffset(limit, offset int) *Pagination

NewLimitOffset creates new limit offset pagination.

func NewPaged added in v0.2.1

func NewPaged(pageNumber, pageSize int) *Pagination

NewPaged creates new page based Pagination.

func (*Pagination) Check

func (p *Pagination) Check() error

Check checks if the given pagination is valid.

func (*Pagination) GetLimitOffset

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

GetLimitOffset gets the 'limit' and 'offset' values from the given pagination.

func (*Pagination) GetNumberSize added in v0.2.1

func (p *Pagination) GetNumberSize() (pageNumber, pageSize int)

GetNumberSize gets the 'page number' and 'page size' from the pagination.

func (*Pagination) IsZero added in v0.2.1

func (p *Pagination) IsZero() bool

IsZero checks if the pagination were already set.

func (*Pagination) SetLimitOffset added in v0.2.1

func (p *Pagination) SetLimitOffset()

SetLimitOffset sets the Pagination from the PageType into OffsetType.

func (*Pagination) SetType

func (p *Pagination) SetType(tp Type)

SetType sets the pagination type.

func (*Pagination) SetValue added in v0.2.1

func (p *Pagination) SetValue(val int, parameter Parameter)

SetValue sets the pagination value for given parameter.

func (*Pagination) String

func (p *Pagination) String() string

String implements fmt.Stringer interface.

func (*Pagination) Type

func (p *Pagination) Type() Type

Type gets the pagination type.

type Parameter

type Parameter int

Parameter Defines the given paginate paramater type.

const (
	// ParamLimit defines 'limit' of the pagination. Used for 'offset' based paginations.
	ParamLimit Parameter = iota

	// ParamOffset defines 'offset' of the pagination. Used for 'offset' based paginations.
	ParamOffset

	// ParamNumber defines the 'page number' of the pagination. Used for 'page' based paginations.
	ParamNumber

	// ParamSize defines 'page size' of the pagination. Used for 'page' based paginations.
	ParamSize
)

type Type

type Type int

Type is the pagination type definition enum.

const (
	// TpOffset is the 'offset' based pagination type.
	TpOffset Type = iota

	// TpPage is the 'page' based pagination type.
	TpPage
)

func (Type) String

func (t Type) String() string

String implements fmt.Stringer interface.

Jump to

Keyboard shortcuts

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