Documentation ¶
Index ¶
- Constants
- func Paginate(config PaginateRequest) func(db *gorm.DB) *gorm.DB
- func Sort(config map[string]SorterEnum, valid ValidSortColumns) func(db *gorm.DB) *gorm.DB
- type Abstraction
- type Collect
- type DomainWrapper
- type Meta
- type PaginateRequest
- type Pagination
- type Paginator
- type SorterEnum
- type ValidSortColumns
- type WithPaginator
Constants ¶
View Source
const ( PageField = "page" LimitField = "limit" )
Variables ¶
This section is empty.
Functions ¶
func Paginate ¶
func Paginate(config PaginateRequest) func(db *gorm.DB) *gorm.DB
Paginate is a middleware that paginates the query result based on the given configuration.
func Sort ¶
func Sort(config map[string]SorterEnum, valid ValidSortColumns) func(db *gorm.DB) *gorm.DB
Sort is a middleware that sorts the query result based on the given configuration.
Types ¶
type Abstraction ¶
type Abstraction[T any] interface { Set(qry T) DomainWrapper[T] }
func NewRequest ¶
func NewRequest[T any](ctx *gin.Context) Abstraction[T]
type Collect ¶
type Collect[T any] interface { GetDomainData() []T ToDomain(data []T) Collect[T] GetMeta(ctx *gin.Context) Meta }
func NewCollection ¶
NewCollection creates a new collection.
type DomainWrapper ¶
type DomainWrapper[T any] struct { // contains filtered or unexported fields }
func (DomainWrapper[T]) GetPagination ¶
func (t DomainWrapper[T]) GetPagination() PaginateRequest
func (DomainWrapper[T]) GetQry ¶
func (t DomainWrapper[T]) GetQry() T
func (DomainWrapper[T]) GetSort ¶
func (t DomainWrapper[T]) GetSort() map[string]SorterEnum
type Meta ¶
type Meta struct {
Pagination Pagination `json:"pagination"`
}
type PaginateRequest ¶
func (PaginateRequest) GetLimit ¶
func (p PaginateRequest) GetLimit() int
func (PaginateRequest) GetOffset ¶
func (p PaginateRequest) GetOffset() int
type Pagination ¶
type Paginator ¶
type Paginator interface {
GetPaginator() WithPaginator
}
type SorterEnum ¶
type SorterEnum string
const ( SorterEnumAsc SorterEnum = "ASC" SorterEnumDesc SorterEnum = "DESC" )
type ValidSortColumns ¶
type ValidSortColumns []string
type WithPaginator ¶
type WithPaginator struct {
TotalCount int `gorm:"->"`
}
Click to show internal directories.
Click to hide internal directories.