Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAPIEndpoint ¶
func NewOrderBy ¶
func NewOrderBy(params SortParams) string
NewOrderBy constructs the ORDER BY clause based on sorting parameters
Types ¶
type PagingInfo ¶
type PagingInfo[T interface{}] struct {
Links PagingLinks `json:"links"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
TotalPages int `json:"total_pages"`
Rows T `json:"rows,omitempty"`
}
func Paginate ¶
func Paginate[FT any, T any](p PagingParams[FT], query *gorm.DB) (PagingInfo[T], error)
type PagingLinks ¶
PaginationLinks contains links for next and previous pages.
type PagingParams ¶
type PagingParams[FilterType interface{}] struct {
Limit int `json:"limit"`
Page int `json:"page"`
Sort string `json:"sort"`
Order string `json:"order"`
TotalRows int64 `json:"total_rows"`
TotalPages int `json:"total_pages"`
BaseURL string `json:"base_url"`
Filters FilterType `json:"filters"`
}
func InitPagingParams ¶
func (*PagingParams[FilterType]) GetLimit ¶
func (p *PagingParams[FilterType]) GetLimit() int
func (*PagingParams[FilterType]) GetOffset ¶
func (p *PagingParams[FilterType]) GetOffset() int
func (*PagingParams[FilterType]) GetPage ¶
func (p *PagingParams[FilterType]) GetPage() int
func (*PagingParams[FilterType]) GetSort ¶
func (p *PagingParams[FilterType]) GetSort() string
type SortParams ¶
Click to show internal directories.
Click to hide internal directories.