gormutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLimit define the default number of records to be retrieved.
	DefaultLimit = 15

	ASC  = "ASC"
	DESC = "DESC"
)

Variables

This section is empty.

Functions

func Paginate

func Paginate(db *gorm.DB, req *ListOptions, data any) (count int64, err error)

Paginate the query.

func Paginator added in v0.3.1

func Paginator(req *ListOptions) func(db *gorm.DB) *gorm.DB

Paginator returns a gorm scope paginator.

Types

type ListOptions added in v0.3.2

type ListOptions struct {
	// Page
	Page int `form:"page"`

	// Offset
	Offset int `form:"offset"`

	// Limit
	Limit int `form:"limit"`

	// Order asc or desc.
	Order string `form:"order"`

	// Sort field.
	Sort string `form:"sort"`
}

ListOptions contains offset and limit fields.

func (*ListOptions) SetDefaultOptions added in v0.3.2

func (req *ListOptions) SetDefaultOptions()

SetDefaultOptions Set default options if not exist.

Jump to

Keyboard shortcuts

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