query

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLimit

func GetLimit(c *gin.Context) int

func GetPage

func GetPage(c *gin.Context) int

func GetSize

func GetSize(c *gin.Context) int

func Page

func Page(tx *gorm.DB, pageable Pageable) *gorm.DB

func PageWithDefaultOrder

func PageWithDefaultOrder(tx *gorm.DB, pageable Pageable, defaultOrder ...string) *gorm.DB

func PageWithDefaultSort

func PageWithDefaultSort(tx *gorm.DB, pageable Pageable, defaultSort ...Sort) *gorm.DB

Types

type Pageable

type Pageable interface {
	GetPage() int
	GetSize() int
	GetSort() []Sort
	GetLimit() int
	GetOffset() int
	NoSort() bool
}

func GetPageable

func GetPageable(c *gin.Context) Pageable

type Pagination

type Pagination struct {
	Page int    `json:"page"`
	Size int    `json:"size"`
	Sort []Sort `json:"sort"`
}

func (*Pagination) GetLimit

func (p *Pagination) GetLimit() int

func (*Pagination) GetOffset

func (p *Pagination) GetOffset() (offset int)

func (*Pagination) GetPage

func (p *Pagination) GetPage() int

func (*Pagination) GetSize

func (p *Pagination) GetSize() int

func (*Pagination) GetSort

func (p *Pagination) GetSort() []Sort

func (*Pagination) NoSort

func (p *Pagination) NoSort() bool

type Sort

type Sort struct {
	By        string
	Direction string
}

func GetSort

func GetSort(c *gin.Context) []Sort

func (Sort) For

func (s Sort) For(v string) Sort

func (*Sort) String

func (s *Sort) String() string

Jump to

Keyboard shortcuts

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