paging

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPageSize default pagination page size.
	DefaultPageSize = int32(100)
	// MinPageSize minimum pagination page size.
	MinPageSize = int32(1)
	// MaxPageSize maximum pagination page size.
	MaxPageSize = int32(100)
	// ServerSetPageSize .
	ServerSetPageSize = int32(0)
	// SingleResultSet (INTERNAL USE ONLY).
	SingleResultSet = int32(-1)
	// TotalsOnlyResultSet .
	TotalsOnlyResultSet = int32(-2)
)

Variables

This section is empty.

Functions

func PageSize

func PageSize(input int32) int32

PageSize validator.

Types

type Cursor

type Cursor struct {
	OptsHash uint64
	Keys     []string
}

func DecodeCursor

func DecodeCursor(encoded string) (*Cursor, error)

func (*Cursor) Encode

func (c *Cursor) Encode() (string, error)

type KeyComparer

type KeyComparer[T any] func([]string, T) bool

type KeyMapper

type KeyMapper[T any] func(T) []string

type Result

type Result[T any] struct {
	Items     []T
	NextToken string
}

func PaginateSlice

func PaginateSlice[T any](
	s []T,
	size int32,
	token string,
	keyCount int,
	cmp KeyComparer[T],
	mapper KeyMapper[T],
) (*Result[T], error)

Jump to

Keyboard shortcuts

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