pagination

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 2 Imported by: 0

README

gpaginator

gpaginator is a fork of github.com/biezhi/gorm-paginator with a focus on an easier to use, and safer API that is covered by tests

Install

$> go get github.com/RTradeLtd/gpaginator

Usage

For an example of using this with gin-gonic, see example/main.go

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Paged added in v0.0.4

type Paged struct {
	TotalRecord int         `json:"total_record"`
	TotalPage   int         `json:"total_page"`
	Records     interface{} `json:"records"`
	Offset      int         `json:"offset"`
	Limit       int         `json:"limit"`
	Page        int         `json:"page"`
	PrevPage    int         `json:"prev_page"`
	NextPage    int         `json:"next_page"`
}

Paged is the response returned by Paging this should be fed to a http request response. If using gin-gonic, you should use c.JSON(200, Paged)

func Paging

func Paging(p *Param, result interface{}) (*Paged, error)

Paging is used to return a paged result from the database

type Param

type Param struct {
	DB      *gorm.DB
	Page    int
	Limit   int
	OrderBy []string
	ShowSQL bool
}

Param is used to configure the paging query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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