cursor

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 11 Imported by: 9

Documentation

Index

Constants

View Source
const KeysetTagKey = "relay"

Variables

This section is empty.

Functions

func Base64

func Base64[T any](next relay.ApplyCursorsFunc[T]) relay.ApplyCursorsFunc[T]

func DecodeKeysetCursor

func DecodeKeysetCursor(cursor string, keys []string) (map[string]any, error)

func DecodeOffsetCursor

func DecodeOffsetCursor(cursor string) (int, error)

func EncodeKeysetCursor

func EncodeKeysetCursor(node any, keys []string) (string, error)

func EncodeOffsetCursor

func EncodeOffsetCursor(offset int) string

func GCM added in v0.1.0

func GCM[T any](gcm cipher.AEAD) func(next relay.ApplyCursorsFunc[T]) relay.ApplyCursorsFunc[T]

func JSONMarshal added in v0.5.0

func JSONMarshal(v any) ([]byte, error)

func JSONUnmarshal added in v0.5.0

func JSONUnmarshal(data []byte, v any) error

func NewGCM added in v0.1.0

func NewGCM(key []byte) (cipher.AEAD, error)

NewGCM creates a new GCM cipher Concurrent safe: https://github.com/golang/go/issues/41689

func NewKeysetAdapter

func NewKeysetAdapter[T any](finder KeysetFinder[T]) relay.ApplyCursorsFunc[T]

func NewOffsetAdapter

func NewOffsetAdapter[T any](finder OffsetFinder[T]) relay.ApplyCursorsFunc[T]

NewOffsetAdapter creates a relay.ApplyCursorsFunc from an OffsetFinder. If you want to use `last!=nil&&before==nil`, you can't skip totalCount.

Types

type KeysetFinder

type KeysetFinder[T any] interface {
	Find(ctx context.Context, after, before *map[string]any, orderBy []relay.Order, limit int, fromEnd bool) ([]Node[T], error)
	Count(ctx context.Context) (int, error)
}

type Node added in v0.5.0

type Node[T any] interface {
	RelayNode() T
}

type NodeWrapper added in v0.5.0

type NodeWrapper[T any] struct {
	Object any
	Unwrap func() T
}

func (*NodeWrapper[T]) MarshalJSON added in v0.5.0

func (n *NodeWrapper[T]) MarshalJSON() ([]byte, error)

func (*NodeWrapper[T]) RelayNode added in v0.5.0

func (n *NodeWrapper[T]) RelayNode() T

type OffsetFinder

type OffsetFinder[T any] interface {
	Find(ctx context.Context, orderBy []relay.Order, skip, limit int) ([]Node[T], error)
	Count(ctx context.Context) (int, error)
}

type OffsetFinderFunc

type OffsetFinderFunc[T any] func(ctx context.Context, orderBy []relay.Order, skip, limit int) ([]Node[T], error)

func (OffsetFinderFunc[T]) Find

func (f OffsetFinderFunc[T]) Find(ctx context.Context, orderBy []relay.Order, skip, limit int) ([]Node[T], error)

type SelfNode added in v0.5.0

type SelfNode[T any] struct {
	Node T
}

func (*SelfNode[T]) MarshalJSON added in v0.5.0

func (n *SelfNode[T]) MarshalJSON() ([]byte, error)

func (*SelfNode[T]) RelayNode added in v0.5.0

func (n *SelfNode[T]) RelayNode() T

Jump to

Keyboard shortcuts

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