query

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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, defaultOrders ...string) *gorm.DB

func PageWithDefaultSort

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

func WithoutTotal added in v0.0.25

func WithoutTotal(c *gin.Context) *bool

Types

type Pageable

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

func GetPageable

func GetPageable(c *gin.Context) Pageable

type Pagination

type Pagination struct {
	Total        int64  `json:"total"`
	Page         int    `json:"page"`
	Size         int    `json:"size"`
	Sort         []Sort `json:"sort"`
	WithoutTotal *bool  `json:"withoutTotal"`
}

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) GetTotal

func (p *Pagination) GetTotal() int64

func (*Pagination) NoCount added in v0.0.15

func (p *Pagination) NoCount() bool

func (*Pagination) NoSort

func (p *Pagination) NoSort() bool

type Query

type Query struct {
	*gorm.DB
	Pagination
}

func (*Query) Infinite

func (p *Query) Infinite(pageable Pageable) *Query

func (*Query) InfiniteWithDefaultOrder

func (p *Query) InfiniteWithDefaultOrder(pageable Pageable, defaultOrders ...string) *Query

func (*Query) InfiniteWithDefaultSort

func (p *Query) InfiniteWithDefaultSort(pageable Pageable, defaultSorts ...Sort) *Query

func (*Query) Page

func (p *Query) Page(pageable Pageable) *Query

func (*Query) PageWithDefaultOrders

func (p *Query) PageWithDefaultOrders(pageable Pageable, defaultOrders ...string) *Query

func (*Query) PageWithDefaultSorts

func (p *Query) PageWithDefaultSorts(pageable Pageable, defaultSorts ...Sort) *Query

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