model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASC sortDirection = iota
	DESC
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	// contains filtered or unexported fields
}

func (*BaseModel) AfterFind

func (bm *BaseModel) AfterFind(scope *gorm.Scope) (err error)

func (bm *BaseModel) AfterUpdate() error {

} func (bm *BaseModel) AfterSave() error {

}

func (*BaseModel) BeforeSave

func (bm *BaseModel) BeforeSave(scope *gorm.Scope) (err error)

func (*BaseModel) BeforeUpdate

func (bm *BaseModel) BeforeUpdate(scope *gorm.Scope) (err error)

func (*BaseModel) DB

func (bm *BaseModel) DB() *gorm.DB

func (*BaseModel) SetDB

func (bm *BaseModel) SetDB(db *gorm.DB)

func (*BaseModel) SetTX

func (bm *BaseModel) SetTX(db *gorm.DB)

func (*BaseModel) SetTableName

func (bm *BaseModel) SetTableName(tableName string) string

type BaseModeller

type BaseModeller interface {
	DB() *gorm.DB
	SetTX(db *gorm.DB)
}

type Context

type Context interface {
	context.RequestParamContextor
}

type Filter

type Filter struct {
	Key string
	Op  string
	Val interface{}
}

type Model

type Model gorm.DB

func (*Model) Paginate

func (bm *Model) Paginate(model interface{}, c Context, perPage uint) (pagination Pagination, err error)

Model(*Q(&User{}, data, []Sort{}, 1, false)).Paginate(c, perPage)

type Modeller

type Modeller interface {
	BaseModeller
	TableName() string
	Default() interface{}
	ObjArr(filterArr []Filter, sortArr []Sort, limit int, withTrashed bool) (interface{}, error)
	ObjArrPaginate(c Context, perPage uint, filterArr []Filter, sortArr []Sort, limit int, withTrashed bool) (pagination Pagination, err error)
}

type Pagination

type Pagination struct {
	// contains filtered or unexported fields
}

func (*Pagination) Count

func (p *Pagination) Count() uint

func (*Pagination) CurrentPage

func (p *Pagination) CurrentPage() uint

func (*Pagination) FirstItem

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

func (*Pagination) ItemArr

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

func (*Pagination) LastItem

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

func (*Pagination) LastPage

func (p *Pagination) LastPage() uint

func (*Pagination) PerPage

func (p *Pagination) PerPage() uint

func (*Pagination) Total

func (p *Pagination) Total() uint

type Sort

type Sort struct {
	Key       string
	Direction sortDirection
}

Directories

Path Synopsis
types

Jump to

Keyboard shortcuts

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