Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GPaginate ¶ added in v0.5.7
GPaginate is GORM scope function. Paginate calculates the total pages and offset based on current metadata and applies pagination to the Gorm query GPaginate function cares Page and PageSize automatically, you can use your own function to replace it, it just overwrite fields
func QueryContextPaginate ¶ added in v0.5.11
func QueryContextPaginate(ctx context.Context, db *sql.DB, dialect Dialect, query string, m *Metadata, args ...any) (*sql.Rows, error)
QueryContextPaginate calculates the total pages and offset based on the current metadata and applies pagination to the SQL query
Types ¶
type Metadata ¶
type Metadata struct { // Page represents current page Page int `form:"page" json:"page"` // PageSize is capacity of per page items PageSize int `form:"page_size" json:"page_size"` // Sort is string type which defines the sort type of data Sort string `form:"sort" json:"sort"` // SortDirection defines sorted column name SortDirection string `form:"sort_direction" json:"sort_direction"` // TotalRows defines the quantity of total rows TotalRows int64 `json:"total_rows"` // TotalPages defines the quantity of total pages, it's defined based on page size and total rows TotalPages int64 `json:"total_pages"` }
func (*Metadata) SortDirectionParams ¶
func (m *Metadata) SortDirectionParams()
SortDirectionParams function check SortDirection parameter, if it's empty, then it sets ascending order by default
func (*Metadata) SortParams ¶
SortParams function take string parameter of sort and set of Sort value
Click to show internal directories.
Click to hide internal directories.