Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultPageNumber is the default page number for pagination (starts from 1). DefaultPageNumber int = 1 // DefaultPageSize is the default page size for pagination. DefaultPageSize int = 15 // MaxPageSize is the maximum allowed page size to prevent excessive data loading. MaxPageSize int = 1000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Page ¶
type Page[T any] struct { Page int `json:"page"` Size int `json:"size"` Total int64 `json:"total"` Items []T `json:"items"` }
Page represents a paginated response with metadata and items.
func New ¶
New creates a new page from pageable parameters, total count, and items. It ensures items is never nil and returns an empty slice if needed.
func (Page[T]) HasPrevious ¶
HasPrevious returns true if there are pages before the current one.
func (Page[T]) TotalPages ¶
TotalPages returns the total number of pages based on the total count.
Click to show internal directories.
Click to hide internal directories.