paginate

package
v1.0.0-beta.51 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultOffsetColumn = "id"

Variables

This section is empty.

Functions

func SendResponse

func SendResponse[T any](ctx raiden.Context, data ExecuteResult[T]) error

Types

type CursorPaginateDirection

type CursorPaginateDirection string
const (
	CursorPaginateDirectionNext CursorPaginateDirection = "next"
	CursorPaginateDirectionPrev CursorPaginateDirection = "prev"
)

type Driver

type Driver interface {
	Paginate(ctx context.Context, statement string, page, limit int, withCount bool) (data []Item, cont int, err error)
	CursorPaginateNext(ctx context.Context, statement string, cursorRefColumn string, cursor any, limit int, withCount bool) (data []Item, count int, prevCursor any, nextCursor any, err error)
	CursorPaginatePrev(ctx context.Context, statement string, cursorRefColumn string, cursor any, limit int, withCount bool) (data []Item, count int, prevCursor any, nextCursor any, err error)
}

type ExecuteOptions

type ExecuteOptions struct {
	Page  int
	Limit int
	Type  Type

	Cursor          any
	CursorDirection CursorPaginateDirection
	CursorRefColumn string

	WithCount bool
	IsBypass  bool
}

type ExecuteResult

type ExecuteResult[T any] struct {
	Data       []T
	Count      int
	NextCursor any
	PrevCursor any
}

func MarshallResult

func MarshallResult[T any](data ExecuteResult[Item]) (result ExecuteResult[T], err error)

type Executor

type Executor interface {
	Execute(ctx context.Context, statement string) (ExecuteResult[Item], error)
	SetDriver(driver Driver) Executor
}

func New

func New(config *raiden.Config, opts ExecuteOptions) Executor

func NewFromContext

func NewFromContext(ctx raiden.Context, opts ExecuteOptions) Executor

type Item

type Item map[string]any

type SupabaseDriver

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

func (*SupabaseDriver) CursorPaginateNext

func (s *SupabaseDriver) CursorPaginateNext(ctx context.Context, statement string, cursorRefColumn string, cursor any, limit int, withCount bool) ([]Item, int, any, any, error)

func (*SupabaseDriver) CursorPaginatePrev

func (s *SupabaseDriver) CursorPaginatePrev(ctx context.Context, statement string, cursorRefColumn string, cursor any, limit int, withCount bool) ([]Item, int, any, any, error)

func (*SupabaseDriver) Paginate

func (s *SupabaseDriver) Paginate(ctx context.Context, statement string, page, limit int, withCount bool) ([]Item, int, error)

type Type

type Type string

PaginationType defines the type of pagination

const (
	OffsetPagination Type = "offset"
	CursorPagination Type = "cursor"
)

Jump to

Keyboard shortcuts

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