pagination

package
v0.0.0-...-21d0996 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

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) Next

func (p *Pagination) Next() int

Next returns the next. @return int

func (*Pagination) Offset

func (p *Pagination) Offset() int

Offset returns the offset. @return int

func (*Pagination) Page

func (p *Pagination) Page() int

Page returns the page. @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

func (*Pagination) Total

func (p *Pagination) Total() int

Total returns the total. @return int

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

type Query

type Query struct {
	Where  string `json:"where" db:"where"`
	Tasks  string `json:"tasks" db:"tasks"`
	Fields string `json:"fields" db:"fields"` // the fields to be selected
}

Query - query

Jump to

Keyboard shortcuts

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