pagex

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const PageLimit = 20

Variables

This section is empty.

Functions

func Asc added in v1.2.1

func Asc() string

func AvgRaw

func AvgRaw(column, alias string) string

func CaseWhenNull

func CaseWhenNull(column, alias string, defaultValue interface{}) string

func Desc added in v1.2.1

func Desc() string

func FindPageList

func FindPageList[T any](ctx context.Context, cc GormcCacheConn, page *ListReq, orderBy OrderBy, orderKeys map[string]string, fn func(conn *gorm.DB) *gorm.DB) ([]T, int64, error)

func Paginate

func Paginate(page *ListReq) func(db *gorm.DB) *gorm.DB

func SetTableSortAsc

func SetTableSortAsc(key string)

func SetTableSortDesc

func SetTableSortDesc(key string)

func TimeRange

func TimeRange(startTime, endTime *time.Time) func(db *gorm.DB) *gorm.DB

TimeRange example: db.Scopes(gormx.TimeRange(startTime, endTime))

func TimeRangeByTable

func TimeRangeByTable(tableName string, startTime, endTime *time.Time) func(db *gorm.DB) *gorm.DB

TimeRangeByTable example: db.Scopes(gormx.TimeRangeByTable("tableName", startTime, endTime))

Types

type GormcCacheConn

type GormcCacheConn interface {
	QueryNoCacheCtx(ctx context.Context, v interface{}, fn gormc.QueryCtxFn) error
	ExecNoCacheCtx(ctx context.Context, execCtx gormc.ExecCtxFn) error
}

type ListReq

type ListReq struct {
	Page     int    `json:"page,optional,default=1" form:"page,optional,default=1"`
	PageSize int    `json:"pageSize,optional,default=10" form:"pageSize,optional,default=10"`
	Keyword  string `json:"keyword,optional" form:"keyword,optional"`
}

func (*ListReq) Limit

func (page *ListReq) Limit() int

func (*ListReq) Offset

func (page *ListReq) Offset() int

type OrderBy

type OrderBy struct {
	OrderKey string `json:"orderKey"`
	Sort     string `json:"sort"`
}

Jump to

Keyboard shortcuts

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