page

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page[T any, INT constraints.Unsigned] struct {
	PageNo INT `json:"pageNo"` // PageNo specifies the current page number (1-based). For custom JSON field naming,
	// use extra.SetNamingStrategy() from github.com/json-iterator/go.
	PageSize     INT `json:"pageSize"`     // PageSize indicates the number of items per page
	TotalPages   INT `json:"totalPages"`   // TotalPages holds the calculated total number of pages
	TotalRecords INT `json:"totalRecords"` // TotalRecords contains the complete count of dataset records
	Records      []T `json:"records"`      // Records stores the slice of items for the current page
}

Page defines the pagination structure containing metadata and records

func EmptyPage

func EmptyPage[T any, INT constraints.Unsigned](pageNo, pageSize INT) *Page[T, INT]

EmptyPage initializes a pagination structure with zero values

type Pager

type Pager[T any, INT constraints.Unsigned] interface {
	AddRecords(records ...T)
	BuildDBPage() *db.Page[INT]
	BuildPage() *Page[T, INT]
}

Pager defines the interface for pagination operations

func NewPager

func NewPager[T any, INT constraints.Unsigned](pageNo, pageSize, totalRecords INT) Pager[T, INT]

NewPager constructs a paginator instance with sanitized input parameters

Parameters:

  • pageNo: current page number (1-based index)
  • pageSize: number of items per page
  • totalRecords: total number of records

Returns a properly configured Pager instance

Jump to

Keyboard shortcuts

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