paging

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package paging holds the cursor rules every Nexus list shares. Lists are ordered newest first by ID (IDs are UUIDv7 TypeIDs, so their text sorts in creation order), and a page is continued from the last ID it returned. There are no totals: a total on a growing list is expensive and usually an estimate.

Index

Constants

View Source
const (
	// DefaultLimit is the page size when none is asked for.
	DefaultLimit = 50
	// MaxLimit is the largest page a store returns.
	MaxLimit = 500
)

Variables

View Source
var ErrInvalidCursor = errors.New("nexus: invalid cursor")

ErrInvalidCursor reports a cursor that is not an ID from the list it was handed to. It is never treated as "start again from the top".

Functions

func CheckCursor

func CheckCursor(cursor string, prefix id.Prefix) error

CheckCursor accepts "" (the first page) or an ID of the given kind.

func Limit

func Limit(n int) int

Limit clamps a requested page size.

func Trim

func Trim[T any](rows []T, limit int, idOf func(T) string) (page []T, next string)

Trim takes the limit+1 rows a store fetched and returns the page and the cursor for the next one, or "" when this is the last page.

Types

This section is empty.

Jump to

Keyboard shortcuts

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