postgresutils

package
v0.0.0-...-a16b4b9 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 6 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] struct {
	Content       []T
	Page          uint
	Size          uint
	TotalElements uint
	TotalPages    uint
}

func FromOtherPage

func FromOtherPage[SrcPage, DstPage any](
	srcPage Page[SrcPage],
	mapFunc func(SrcPage) DstPage,
) Page[DstPage]

func ListPaginated

func ListPaginated[T any](
	ctx context.Context,
	db *sql.DB,
	q *goqu.SelectDataset,
	pageReq *PageRequest,
	mapRow RowMapper[T],
) (Page[T], error)

func NewPage

func NewPage[T any](content []T, page, size, totalElements uint) Page[T]

type PageRequest

type PageRequest struct {
	Page uint     `in:"query=page"`
	Size uint     `in:"query=size"`
	Sort []string `in:"query=sort"`
}

func (PageRequest) ApplyPagination

func (p PageRequest) ApplyPagination(q *goqu.SelectDataset) *goqu.SelectDataset

type RowMapper

type RowMapper[T any] func(rows *sql.Rows) (T, error)

type Scanner

type Scanner interface {
	Scan(dest ...interface{}) error
}

Jump to

Keyboard shortcuts

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