Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPageRequest ¶
func DefaultPageRequest() *pageRequest
DefaultPageRequest returns a pageRequest with default settings.
func PageRequestFrom ¶
func PageRequestFrom[T interface{ ~int | ~string }](pageNumber, pageSize T, options ...PageOptions) (*pageRequest, error)
PageRequestFrom constructs a pageRequest from given page number, page size, and options.
Types ¶
type Page ¶
type Page[T any] struct { // Total number of items available (no paging involved) Total int64 // Current page elements Elements []T }
Page represents a paginated result containing total item count and current page elements.
type PageOptions ¶
type PageOptions func(*pageRequest) error
PageOptions is a function that modifies a pageRequest, often used for optional configurations.
func WithFilter ¶
func WithFilter(filter any) PageOptions
WithFilter adds a filter struct to the pageRequest.
func WithSortOrder ¶
func WithSortOrder(by string, direction sort.Direction) PageOptions
WithSortOrder adds a sorting order to the pageRequest.
type Pageable ¶
type Pageable interface {
// PageNumber returns the current page number (starting from 1).
PageNumber() int
// PageSize returns the number of items per page.
PageSize() int
// SortOrders returns a list of sort.Order specifying sorting criteria.
SortOrders() []sort.Order
// Paginate applies pagination limits and offsets to the GORM DB instance.
Paginate(*gorm.DB) (*gorm.DB, error)
// Order applies sorting orders to the GORM DB instance.
Order(*gorm.DB) (*gorm.DB, error)
// Filter applies filtering criteria to the GORM DB instance.
Filter(*gorm.DB) (*gorm.DB, error)
}
Pageable defines an interface for pagination, sorting, and filtering capabilities that can be applied to a GORM DB query.
Click to show internal directories.
Click to hide internal directories.