cursor

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 11 Imported by: 3

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[T any](cursor string, keys []string) (map[string]any, error)

func DecodeOffsetCursor

func DecodeOffsetCursor(cursor string) (int, error)

func EncodeKeysetCursor

func EncodeKeysetCursor[T any](node T, 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) relay.CursorMiddleware[T]

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, orderBys []relay.OrderBy, limit int, fromEnd bool) ([]T, error)
	Count(ctx context.Context) (int, error)
}

type OffsetFinder

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

type OffsetFinderFunc

type OffsetFinderFunc[T any] func(ctx context.Context, orderBys []relay.OrderBy, skip, limit int) ([]T, error)

func (OffsetFinderFunc[T]) Find

func (f OffsetFinderFunc[T]) Find(ctx context.Context, orderBys []relay.OrderBy, skip, limit int) ([]T, error)

Jump to

Keyboard shortcuts

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