Skip to content

manuelarte/pagorminator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Go coverage Go Report Card

๐Ÿ“ƒ pagorminator

Gorm plugin to add pagination to your select queries

โฌ‡๏ธ How to install it

go get -u -v github.com/manuelarte/pagorminator

๐ŸŽฏ How to use it

DB.Use(pagorminator.PaGormMinator{})
var products []*Products
pageRequest, err := pagorminator.PageRequest(0, 10)
DB.Clauses(pageRequest).First(&products)

The plugin will calculate the total amount of elements so then the fields total amounts and total pages can be used too. The pagination starts at index 0. So if the total pages is 6, then the pagination index goes from 0 to 5.

๐ŸŽ“ Examples

Simple query with no filters (where clause)

Simple query with no filters (where clause), many pages

Using where to filter

Unpaged query

Example using Preload

๐Ÿ”— Contact