db

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: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithMaxPageSize added in v0.13.0

func WithMaxPageSize[INT constraints.Unsigned](maxPageSize INT) func(*Page[INT])

WithMaxPageSize configures the maximum allowed page size for pagination parameters validation.

Types

type OrderBy

type OrderBy []OrderByPair

OrderBy collects multiple sorting criteria for query

func OneOrderBy

func OneOrderBy(name string, direction OrderByDirection) OrderBy

OneOrderBy creates OrderBy with single sorting pair

func TwoOrderBy

func TwoOrderBy(name0 string, direction0 OrderByDirection, name1 string, direction1 OrderByDirection) OrderBy

TwoOrderBy creates OrderBy with two sorting pairs

func (OrderBy) String

func (ob OrderBy) String() string

String formats sorting criteria as SQL ORDER BY clause

func (OrderBy) Strings added in v0.14.0

func (ob OrderBy) Strings() []string

Strings returns slice of formatted sorting expressions

type OrderByDirection

type OrderByDirection string

OrderByDirection defines sorting direction for SQL ORDER BY clause

var (
	// ASC ascending sort order
	ASC OrderByDirection = "ASC"
	// DESC descending sort order
	DESC OrderByDirection = "DESC"
)

type OrderByPair

type OrderByPair struct {
	Name      string
	Direction OrderByDirection
}

OrderByPair represents a field and its sorting direction pair

func (OrderByPair) String

func (pair OrderByPair) String() string

type Page

type Page[INT constraints.Unsigned] struct {
	// contains filtered or unexported fields
}

Page defines pagination parameters for query operations

func NewPage

func NewPage[INT constraints.Unsigned](pageNo, pageSize INT, opts ...func(*Page[INT])) (pg *Page[INT])

NewPage creates pagination parameters with validation

func (*Page[INT]) Limit

func (pg *Page[INT]) Limit() INT

Limit returns configured items per page

func (*Page[INT]) Offset

func (pg *Page[INT]) Offset() INT

Offset returns SQL OFFSET clause value

func (*Page[INT]) PageNo

func (pg *Page[INT]) PageNo() INT

PageNo returns current page number

func (*Page[INT]) PageSize

func (pg *Page[INT]) PageSize() INT

PageSize returns configured items per page

func (*Page[INT]) TotalPages

func (pg *Page[INT]) TotalPages(totalRecords INT) (totalPages INT)

TotalPages calculates total pages based on total records count

Jump to

Keyboard shortcuts

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