pageable

package module
v0.0.0-...-45c4fb7 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 3 Imported by: 0

README

Description

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	Type string
}

func NewDriver

func NewDriver(dbType string) (*Driver, error)

func (*Driver) Paginate

func (d *Driver) Paginate(db *sql.DB, tableName string, page, size int, sort string) (*Response, error)

type PaginationDetail

type PaginationDetail struct {
	Offset     int        `json:"offset"`
	PageNumber int        `json:"pageNumber"`
	PageSize   int        `json:"pageSize"`
	Paged      bool       `json:"paged"`
	Unpaged    bool       `json:"unpaged"`
	Sort       SortDetail `json:"sort"`
}

type Response

type Response struct {
	Content          interface{}      `json:"content"`
	Pageable         PaginationDetail `json:"pageable"`
	TotalElements    int              `json:"totalElements"`
	Last             bool             `json:"last"`
	TotalPages       int              `json:"totalPages"`
	First            bool             `json:"first"`
	Size             int              `json:"size"`
	Number           int              `json:"number"`
	Sort             SortDetail       `json:"sort"`
	NumberOfElements int              `json:"numberOfElements"`
	Empty            bool             `json:"empty"`
}

func NewPaginatedResponse

func NewPaginatedResponse(data interface{}, dataCount int, totalCount int64, page int, limit int, sort string) *Response

func PaginateSQL

func PaginateSQL(db *sql.DB, tableName string, page, size int, sort string) (Response, error)

type SortDetail

type SortDetail struct {
	Sorted   bool `json:"sorted"`
	Empty    bool `json:"empty"`
	Unsorted bool `json:"unsorted"`
}

func NewSortDetail

func NewSortDetail(sort string) SortDetail

Jump to

Keyboard shortcuts

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