pagination

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package pagination implements stable created-time and TypeID continuation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(entity ctrlplane.Entity) string

Encode returns an opaque continuation for an entity.

func Page

func Page[T any](items []T, cursor string, limit int, key func(T) ctrlplane.Entity) ([]T, string, int, error)

Page sorts an already scoped collection and applies continuation without requiring the anchor to still exist.

func Trim

func Trim[T any](items []T, limit int, key func(T) ctrlplane.Entity) ([]T, string)

Trim removes the lookahead row and reports continuation only when more rows exist.

Types

type Position

type Position struct {
	CreatedAt time.Time `json:"created_at"`
	ID        id.ID     `json:"id"`
}

Position is the last returned entity in descending creation order.

func Decode

func Decode(cursor string) (Position, error)

Decode validates a cursor. An empty cursor starts at the newest entity.

Jump to

Keyboard shortcuts

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