repo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultPage     = 1
	DefaultPageSize = 10
	MaxPageSize     = 500
)
View Source
const (
	DescOrderPrefix = "-"
	AscOrderPrefix  = "+"
	DefaultOrderBy  = "id desc"
)

Variables

This section is empty.

Functions

func ArrayToQueryOrder

func ArrayToQueryOrder(s []string) string

func CtxWithDB

func CtxWithDB(ctx context.Context, db *gorm.DB) context.Context

func GetDBFromCtx

func GetDBFromCtx(ctx context.Context) *gorm.DB

func WhereInIds

func WhereInIds(db *gorm.DB, id uint, ids ...uint) *gorm.DB

Types

type Pager

type Pager struct {
	Page     int `form:"page" json:"page"`
	PageSize int `form:"pageSize" json:"pageSize"`
}

type Paginator

type Paginator[T any] struct {
	Pager
	Total int `json:"total"`
	Data  []T `json:"data"`
}

func FindEntityByPage

func FindEntityByPage[V any](ctx context.Context, page, limit int) (*Paginator[V], error)

Jump to

Keyboard shortcuts

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