pagi

package
v0.0.0-...-857c71f Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pagi provides utilities for implementing pagination in Go applications. It includes structures and methods for calculating page numbers, limits, and offsets based on total item counts and user-defined page sizes. This package aims to simplify the process of adding pagination to data-driven applications, ensuring efficient data retrieval and presentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithInterceptor

func WithInterceptor[T any](query T, opts ...InterceptorOption) T

Types

type InterceptorOption

type InterceptorOption func(*sql.Selector)

func WithFilter

func WithFilter(filterExp string, filterArgs []interface{}) InterceptorOption

func WithLimitOffset

func WithLimitOffset(limit int, offset int) InterceptorOption

func WithSelect

func WithSelect(selects ...string) InterceptorOption

func WithSort

func WithSort(sort ...string) InterceptorOption

type Meta

type Meta struct {
	Limit  int  `json:"limit"`
	Offset int  `json:"offset"`
	Total  *int `json:"total"`
}

type Param

type Param struct {
	Limit  int            `json:"limit"`
	Offset int            `json:"offset"`
	Filter map[string]any `json:"filter"`
	Sort   []string       `json:"sort"`
}

type Response

type Response[T any] struct {
	Data []T   `json:"data"`
	Meta *Meta `json:"meta"`
}

Jump to

Keyboard shortcuts

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