database

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPageSize = 10
	MaxPageSize = 50
)

Variables

View Source
var (
	ErrBadSortAttribute = errors.New("bad sorting attribute")
)

Functions

func DropSchema

func DropSchema(dsn string) error

func Migrate

func Migrate(dsn string) error

func New added in v0.0.5

func New(dsn string) (*gorm.DB, error)

func Paginate added in v0.0.6

func Paginate(value interface{}, p Paginable, db *gorm.DB) func(db *gorm.DB) *gorm.DB

func RegisterModels added in v0.0.5

func RegisterModels(objs ...interface{})

Types

type Paginable added in v0.0.10

type Paginable interface {
	SetTotalRows(int64)
	GetOffset() int
	GetLimit() int
	GetSort() interface{}
}

type Pagination added in v0.0.6

type Pagination struct {
	Limit     int         `json:"limit,omitempty" form:"limit"`
	Offset    int         `json:"offset,omitempty" form:"offset"`
	Sort      string      `json:"sort,omitempty" form:"sort"`
	SortDesc  bool        `json:"sort_desc" form:"sort_desc"`
	TotalRows int64       `json:"total_rows"`
	Rows      interface{} `json:"rows"`
}

func (*Pagination) GetLimit added in v0.0.6

func (p *Pagination) GetLimit() int

func (*Pagination) GetOffset added in v0.0.10

func (p *Pagination) GetOffset() int

func (*Pagination) GetSort added in v0.0.6

func (p *Pagination) GetSort() interface{}

func (*Pagination) SetTotalRows added in v0.0.10

func (p *Pagination) SetTotalRows(rows int64)

Jump to

Keyboard shortcuts

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