model

package
v0.1.0-nightly.1551855715 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ASC sortDirection = iota
	DESC
)

Variables

This section is empty.

Functions

func Connection

func Connection(conn string) (_db *gorm.DB)

func Count

func Count(in Modeller, filterArr []Filter, withTrashed bool) (count uint, err error)

func Create

func Create(out interface{}) error

out must be a struct pointer

func DB

func DB() *gorm.DB

func Delete

func Delete(in interface{}, force bool) error

func Exist

func Exist(in Modeller, withTrashed bool) (exist bool)

func First

func First(out interface{}, withTrashed bool) error

out must be a struct pointer

func Initialize

func Initialize()

func NewMysql

func NewMysql(connection string) *mysql

func Q

func Q(filterArr []Filter, sortArr []Sort, limit int, withTrashed bool) *gorm.DB

func Restore

func Restore(in interface{}) error

func Save

func Save(out interface{}, modify interface{}) error

out must be a struct pointer

func SaveByID

func SaveByID(id interface{}, out interface{}, modify interface{}) error

func Transaction

func Transaction(f func(), attempts uint)

Types

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 *gin.Context, perPage uint) (pagination Pagination, err error)

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

type Modeller

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

type OrmConfigurator

type OrmConfigurator interface {
	ConnectionArgs() string
	Driver() string
	Prefix() string
}

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

Jump to

Keyboard shortcuts

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