gormx

package
v0.0.0-...-5117fa9 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDb

func NewDb(config map[string]interface{}) (*gorm.DB, error)

Types

type Builder

type Builder struct {
	Pageinfo *paginate.PageInfo
	Total    int32
	// contains filtered or unexported fields
}

配合gorm的查询构建器,方便做一个分页相关的处理,及数据库获取数据

func HandleListFetchRequest

func HandleListFetchRequest(db *gorm.DB, ls interface{}, req *request.FetchRequest) (*Builder, error)

ls must be point to struct you can pass ls value like :

var data []fund.FundProd
gormx.HandleListFetchRequest(app.Db,id,&data,req)

func HandleNodeRequest

func HandleNodeRequest(db *gorm.DB, id interface{}, ls interface{}, req *request.NodeRequest) (*Builder, error)

ls must be point to struct you can pass ls value like :

data := &fund.FundProd{}
gormx.HandleNodeRequest(app.Db,id,data,req)

func NewBuilder

func NewBuilder(db *gorm.DB) *Builder

初始化builder,如果需要统计时,请先初始化DB.Table或Model

func (*Builder) Field

func (t *Builder) Field(field string) *Builder

func (*Builder) GetCountDb

func (t *Builder) GetCountDb() *gorm.DB

func (*Builder) GetDb

func (t *Builder) GetDb() *gorm.DB

func (*Builder) GetPageInfo

func (t *Builder) GetPageInfo(count int) (*paginate.PageInfo, int32)

func (*Builder) Order

func (t *Builder) Order(order string) *Builder

func (*Builder) PaginateCursor

func (t *Builder) PaginateCursor(p *paginate.Pagination) *Builder

func (*Builder) PaginateOffSet

func (t *Builder) PaginateOffSet(p *paginate.Pagination, needTotal bool) *Builder

func (*Builder) Prepare

func (t *Builder) Prepare() *gorm.DB

返回即将执行的的Db

func (*Builder) SetDb

func (t *Builder) SetDb(db *gorm.DB)

func (*Builder) Where

func (t *Builder) Where(where string, params map[string]string) *Builder

only support string params,only parameter which start low case will set to where parameters

type GormLog

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

gorm zap GormLog

func CreateGormLog

func CreateGormLog(values []interface{}) *GormLog

func (*GormLog) ToZapFields

func (l *GormLog) ToZapFields() []zapcore.Field

Jump to

Keyboard shortcuts

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