page

package
v0.0.0-...-74e38f5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldPage   = "page"
	FieldLimit  = "limit"
	FieldOffset = "offset"
	FieldSort   = "sort"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page struct {
	Fields map[string][]string

	// Count is used to determine the amount of results returned from the query.
	Count int

	// Limit is used to determine the total amount requested for the query.
	Limit int

	// Offset is used to determine where the cursor in the query should start.
	Offset int

	// Total is used to tell how many total results are available to query. A value of 0 or less can be considered as
	// unset.
	Total int
}

Count, Limit, Offset, Total are used for setting results of a query. The query performed may change any of these properties due to limitations or desired logic.

func NewPage

func NewPage() *Page

func NewPageFromMap

func NewPageFromMap(m map[string][]string) *Page

func (*Page) Add

func (p *Page) Add(key string, value ...string) *Page

func (*Page) ApplyDefault

func (p *Page) ApplyDefault(key string, values ...string) *Page

func (*Page) ApplyPageNumber

func (p *Page) ApplyPageNumber(num, limit int) *Page

func (*Page) Bool

func (p *Page) Bool(key string) bool

func (*Page) Clone

func (p *Page) Clone() *Page

func (*Page) CopyFrom

func (p *Page) CopyFrom(b *Page, keys ...string) *Page

func (*Page) Default

func (p *Page) Default(key, replacement string) string

func (*Page) DefaultBool

func (p *Page) DefaultBool(key string, replacement bool) bool

func (*Page) DefaultInt

func (p *Page) DefaultInt(key string, replacement int) int

func (*Page) Delete

func (p *Page) Delete(key string) *Page

func (*Page) Exists

func (p *Page) Exists(key string) bool

func (*Page) Get

func (p *Page) Get(key string) (string, bool)

func (*Page) GetBool

func (p *Page) GetBool(key string) (bool, bool)

func (*Page) GetBooleans

func (p *Page) GetBooleans(key string) ([]bool, bool)

func (*Page) GetCSV

func (p *Page) GetCSV(key string) []string

Use this to take all CSV values of a key into a single array.

func (*Page) GetInt

func (p *Page) GetInt(key string) (int, bool)

func (*Page) GetIntegers

func (p *Page) GetIntegers(key string) ([]int, bool)

func (*Page) GetPageNumber

func (p *Page) GetPageNumber() (int, bool)

This is special logic that is commonly used. The page number should be 1 to infinity in any instance thus we use this logic throughout applications.

func (*Page) GetSorts

func (p *Page) GetSorts() []string

func (*Page) Int

func (p *Page) Int(key string) int

func (*Page) PageNumber

func (p *Page) PageNumber() int

func (*Page) Set

func (p *Page) Set(key string, values ...string) *Page

func (*Page) SetBool

func (p *Page) SetBool(key string, values ...bool) *Page

func (*Page) SetCSV

func (p *Page) SetCSV(key string, values ...string) *Page

func (*Page) SetInt

func (p *Page) SetInt(key string, values ...int) *Page

func (*Page) SetSort

func (p *Page) SetSort(sorts ...string) *Page

func (*Page) Str

func (p *Page) Str(key string) string

Jump to

Keyboard shortcuts

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