repo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(input string) string

func Expr

func Expr(expression string, args ...interface{}) interface{}

Types

type Expression

type Expression func(db *gorm.DB) *gorm.DB

func Group

func Group(query string) Expression

func Join

func Join(query string, args ...interface{}) Expression

func Model

func Model(value interface{}) Expression

func Order

func Order(value interface{}) Expression

func Page

func Page(pageNum int, perCount int) Expression

func Select

func Select(query interface{}, args ...interface{}) Expression

func Table

func Table(name string) Expression

func Where

func Where(query interface{}, args ...interface{}) Expression

type FieldName

type FieldName struct {
	Username string
	Password string
	Host     string
	Port     string
	DbName   string
}

FieldName 字段类

type Option

type Option func(*Repository)

Option 配置函数

func Addr

func Addr(addr string) Option

func DbName

func DbName(dbName string) Option

DbName 数据库名配置

func Host

func Host(host string) Option

Host 服务器配置

func LogMode

func LogMode(mode bool) Option

func Port

func Port(port string) Option

Port 端口配置

func Pwd

func Pwd(password string) Option

Pwd 密码配置

func UserName

func UserName(userName string) Option

UserName 用户名配置

type Repository

type Repository struct {
	*gorm.DB
	Logger *log.ZapLogger
	// contains filtered or unexported fields
}

Repository 仓储类

func New

func New(options ...Option) *Repository

New 构造函数

func (*Repository) Exist

func (repo *Repository) Exist(out interface{}, where ...interface{}) (e error)

func (*Repository) Insert

func (repo *Repository) Insert(val interface{}) (e error)

Insert 新增

func (*Repository) Migrate

func (repo *Repository) Migrate(initial func(*Repository), values ...interface{})

func (*Repository) Modify

func (repo *Repository) Modify(val interface{}) (e error)

Modify 修改

func (*Repository) ModifyColumn

func (repo *Repository) ModifyColumn(val interface{}, attr string, upValue interface{}, where ...interface{}) (affects int64, e error)

更改单个字段

func (*Repository) ModifyColumns

func (repo *Repository) ModifyColumns(val interface{}, columns interface{}, where ...interface{}) (affects int64, e error)

更改多个字段

func (*Repository) ModifyFunc

func (repo *Repository) ModifyFunc(val interface{}, modifier func(interface{}), where ...interface{}) (e error)

ModifyFunc 使用函数更新

func (*Repository) Print

func (repo *Repository) Print(args ...interface{})

func (*Repository) Query

func (repo *Repository) Query(out interface{}, count bool, exps ...Expression) (c int, e error)

Query 查询列表(可分页)

func (*Repository) Read

func (repo *Repository) Read(out interface{}, where ...interface{}) (e error)

Read 查询单条记录

func (*Repository) ReadAll

func (repo *Repository) ReadAll(out interface{}, where ...interface{}) (e error)

ReadAll 查询单条

func (*Repository) ReadAllWithOrderBy

func (repo *Repository) ReadAllWithOrderBy(out interface{}, orderby interface{}, where ...interface{}) (e error)

func (*Repository) ReadWithOrderBy

func (repo *Repository) ReadWithOrderBy(out interface{}, orderby interface{}, where ...interface{}) (e error)

Read 查询单条记录

func (*Repository) Remove

func (repo *Repository) Remove(val interface{}, where ...interface{}) (e error)

Remove 删除

func (*Repository) RemoveWithAffect

func (repo *Repository) RemoveWithAffect(val interface{}, where ...interface{}) (affects int64, e error)

Remove 获取影响行数

func (*Repository) SoftRemove

func (repo *Repository) SoftRemove(value interface{}, where ...interface{}) (e error)

func (*Repository) Transaction

func (repo *Repository) Transaction(f func(*Repository) error) (e error)

Transaction 执行包装事务

Jump to

Keyboard shortcuts

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