commons

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPaginationLimit = 1000

Variables

View Source
var ErrInvalidCursor = errors.New("invalid pagination cursor")
View Source
var ErrInvalidLimit = errors.New("limit cannot be negative")
View Source
var ErrMixedPagination = errors.New(
	"cannot mix forward pagination (first, after) with backward pagination (last, before)")

Functions

func ComputePage

func ComputePage(
	first *int, last *int, after *string, before *string, total int,
) (offset int, limit int, err error)

Compute the pagination parameters given the GraphQL connection parameters.

func ConfigureLog

func ConfigureLog(level slog.Leveler)

func DecodeCursor

func DecodeCursor(base64Cursor string, total int) (int, error)

Decode the integer offset from a base64 string.

func EncodeCursor

func EncodeCursor(offset int) string

Encode the integer offset into a base64 string.

Types

type PageResult

type PageResult[T any] struct {
	Total  uint64
	Offset uint64
	Rows   []T
}

Jump to

Keyboard shortcuts

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