cursor

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCursor = errors.New("invalid cursor")
	ErrInvalidModel  = errors.New("invalid model")
)

Errors for encoder

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	After  *string `json:"after" query:"after"`
	Before *string `json:"before" query:"before"`
}

Cursor cursor data

type CustomType added in v2.3.0

type CustomType interface {
	// GetCustomTypeValue returns the value corresponding to the meta attribute inside the custom type.
	GetCustomTypeValue(meta interface{}) (interface{}, error)
}

CustomType is an interface that custom types need to implement in order to allow pagination over fields inside custom types.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder cursor decoder

func NewDecoder

func NewDecoder(fields []DecoderField) *Decoder

NewDecoder creates cursor decoder for model

func (*Decoder) Decode

func (d *Decoder) Decode(cursor string, model interface{}) (fields []interface{}, err error)

Decode decodes cursor into values (without pointer) by referencing field type on model.

func (*Decoder) DecodeStruct

func (d *Decoder) DecodeStruct(cursor string, model interface{}) (err error)

DecodeStruct decodes cursor into model, model must be a pointer to struct or it will panic.

type DecoderField added in v2.3.0

type DecoderField struct {
	Key  string
	Type *reflect.Type
}

DecoderField contains information about one decoder field.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder cursor encoder

func NewEncoder

func NewEncoder(fields []EncoderField) *Encoder

NewEncoder creates cursor encoder

func (*Encoder) Encode

func (e *Encoder) Encode(model interface{}) (string, error)

Encode encodes model into cursor

type EncoderField added in v2.3.0

type EncoderField struct {
	Key string
	// metas are needed for handling of custom types
	Meta interface{}
}

EncoderField contains information about one encoder field.

Jump to

Keyboard shortcuts

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