cursor

package
v0.0.0-...-7bb74a7 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const KeysetTagKey = "relay"

Variables

This section is empty.

Functions

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 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`, the finder must implement Counter.

func WrapAES

func WrapAES[T any](next relay.ApplyCursorsFunc[T], encryptionKey []byte) relay.ApplyCursorsFunc[T]

func WrapBase64

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

Types

type Counter

type Counter interface {
	Count(ctx context.Context) (int, error)
}

type KeysetFinder

type KeysetFinder[T any] interface {
	Find(ctx context.Context, after, before *map[string]any, orderBys []relay.OrderBy, limit int, fromLast bool) ([]T, error)
}

type KeysetFinderFunc

type KeysetFinderFunc[T any] func(ctx context.Context, after, before *map[string]any, orderBys []relay.OrderBy, limit int, fromLast bool) ([]T, error)

func (KeysetFinderFunc[T]) Find

func (f KeysetFinderFunc[T]) Find(ctx context.Context, after, before *map[string]any, orderBys []relay.OrderBy, limit int, fromLast bool) ([]T, error)

type OffsetFinder

type OffsetFinder[T any] interface {
	Find(ctx context.Context, orderBys []relay.OrderBy, skip, limit int) ([]T, 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