mysqlwrap

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorInit = 1 + iota
	ErrorQuery
	ErrorInsert
	ErrorUpdate
	ErrorDelete
	ErrorClose
	ErrorTxBegin
	ErrorTxCommit
	ErrorTxRollback
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mysql

type Mysql struct {
	*MysqlExecutor
	DbMap *gorp.DbMap

	Transaction *gorp.Transaction
	// contains filtered or unexported fields
}

func New

func New(options Options) *Mysql

func NewFromUrl added in v1.0.3

func NewFromUrl(mysqlUrl string) *Mysql

NewFromUrl mysqlUrl:root:6plzHiJKdUMlFZ@tcp(test.iqidao.com:43122)/good?charset=utf8mb4&MaxOpen=2000&MaxIdle=10&MaxLifetime=60

func (*Mysql) AddTable

func (m *Mysql) AddTable(t interface{})

func (*Mysql) Close

func (m *Mysql) Close()

func (*Mysql) WithTx

func (m *Mysql) WithTx(fn func())

type MysqlExecutor

type MysqlExecutor struct {
	gorp.SqlExecutor
}

func WrapExecutor

func WrapExecutor(executor gorp.SqlExecutor) *MysqlExecutor

func (*MysqlExecutor) Delete

func (m *MysqlExecutor) Delete(table string, idField string, id int) sql.Result

func (*MysqlExecutor) Deletes

func (m *MysqlExecutor) Deletes(table string, idField string, ids []int) sql.Result

func (*MysqlExecutor) Exec

func (m *MysqlExecutor) Exec(query string, args ...interface{}) sql.Result

func (*MysqlExecutor) Get

func (m *MysqlExecutor) Get(result interface{}, table string, idField string, id interface{})

func (*MysqlExecutor) GetBy

func (m *MysqlExecutor) GetBy(result interface{}, table string, kvs map[string]interface{})

func (*MysqlExecutor) GetTable

func (m *MysqlExecutor) GetTable(result interface{}, id interface{})

func (*MysqlExecutor) Insert added in v1.0.3

func (m *MysqlExecutor) Insert(obj interface{})

func (*MysqlExecutor) Inserts

func (m *MysqlExecutor) Inserts(list ...interface{})

func (*MysqlExecutor) List

func (m *MysqlExecutor) List(result interface{}, table string, idField string, ids []int)

func (*MysqlExecutor) ListBy

func (m *MysqlExecutor) ListBy(result interface{}, table string, kvs map[string]interface{})

func (*MysqlExecutor) ListByStrIds

func (m *MysqlExecutor) ListByStrIds(result interface{}, table string, idField string, ids []string)

func (*MysqlExecutor) Patch

func (m *MysqlExecutor) Patch(table string, idField string, params interface{}) sql.Result

Patch update table by idFieldidField must in params ,update `table` set k1=v1,k2=v2 where `idField`=params[idField]

func (*MysqlExecutor) PatchArgs added in v1.0.9

func (m *MysqlExecutor) PatchArgs(table string, idField string, idValue interface{}, kvs ...interface{}) sql.Result

PatchArgs .update `table` set k1=v1,k2=v2 where `idField`=id ,

func (*MysqlExecutor) Select

func (m *MysqlExecutor) Select(result interface{}, query string, args ...interface{})

func (*MysqlExecutor) SelectFloat

func (m *MysqlExecutor) SelectFloat(query string, args ...interface{}) int64

func (*MysqlExecutor) SelectInt

func (m *MysqlExecutor) SelectInt(query string, args ...interface{}) int64

func (*MysqlExecutor) SelectNullFloat

func (m *MysqlExecutor) SelectNullFloat(query string, args ...interface{}) null.Float

func (*MysqlExecutor) SelectNullInt

func (m *MysqlExecutor) SelectNullInt(query string, args ...interface{}) null.Int

func (*MysqlExecutor) SelectNullStr

func (m *MysqlExecutor) SelectNullStr(query string, args ...interface{}) null.String

func (*MysqlExecutor) SelectOne

func (m *MysqlExecutor) SelectOne(result interface{}, query string, args ...interface{})

func (*MysqlExecutor) SelectStr

func (m *MysqlExecutor) SelectStr(query string, args ...interface{}) string

func (*MysqlExecutor) Updates

func (m *MysqlExecutor) Updates(list ...interface{}) int64

func (*MysqlExecutor) With

func (m *MysqlExecutor) With(ctx context.Context)

type Options

type Options struct {
	Url         string
	MaxIdle     int
	MaxOpen     int
	MaxLifetime int
}

Jump to

Keyboard shortcuts

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