db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchInsert added in v0.0.3

func BatchInsert(m ConnInterface, batch *sql.Batch) (int64, error)

func Delete added in v0.0.3

func Delete(m ConnInterface, del *sql.Delete) (int64, error)

func Exec added in v0.0.3

func Exec(m ConnInterface, stament string) error

func FetchAll added in v0.0.3

func FetchAll(m ConnInterface, table string, where map[string]interface{}, t interface{}) ([]interface{}, error)

func FetchAllByWhere added in v0.0.6

func FetchAllByWhere(m ConnInterface, table string, where *sql.Where, t interface{}) ([]interface{}, error)

func FetchPage added in v0.0.6

func FetchPage(m ConnInterface, table string, where map[string]interface{}, t interface{}, page int, pageSize int) ([]interface{}, error)

func FetchPageByWhere added in v0.0.6

func FetchPageByWhere(m ConnInterface, table string, where *sql.Where, t interface{}, page int, pageSize int) ([]interface{}, error)

func FetchRow added in v0.0.3

func FetchRow(m ConnInterface, table string, where map[string]interface{}, t interface{}) (interface{}, error)

func Init

func Init(conf config.Mysql) error

func Insert added in v0.0.3

func Insert(m ConnInterface, insert *sql.Insert) (int64, error)

func OpenDB added in v0.0.2

func OpenDB(conf config.Mysql) (*sql.DB, error)

func Query added in v0.0.3

func Query(m ConnInterface, query string, t interface{}, args ...interface{}) ([]interface{}, error)

func Select added in v0.0.3

func Select(m ConnInterface, sel *sql.Select, t interface{}) ([]interface{}, error)

func Update added in v0.0.3

func Update(m ConnInterface, update *sql.Update) (int64, error)

Types

type ConnInterface added in v0.0.3

type ConnInterface interface {
	Query(string, ...interface{}) (*ds.Rows, error)
	Exec(string, ...interface{}) (ds.Result, error)
	Prepare(string) (*ds.Stmt, error)
	QueryRow(string, ...interface{}) *ds.Row
}

type DbInterface added in v0.0.3

type DbInterface interface {
	Begin() error
	Commit() error
	RollBack() error
	InTransaction() bool
	Query(string, interface{}, ...interface{}) ([]interface{}, error)
	Exec(string) error
	Insert(*sql.Insert) (int64, error)
	Update(*sql.Update) (int64, error)
	Delete(*sql.Delete) (int64, error)
	BatchInsert(*sql.Batch) (int64, error)
	Select(*sql.Select, interface{}) ([]interface{}, error)
	FetchRow(string, map[string]interface{}, interface{}) (interface{}, error)
	FetchAll(string, map[string]interface{}, interface{}) ([]interface{}, error)
	FetchAllByWhere(string, *sql.Where, interface{}) ([]interface{}, error)
	FetchPage(string, map[string]interface{}, interface{}, int, int) ([]interface{}, error)
	FetchPageByWhere(string, *sql.Where, interface{}, int, int) ([]interface{}, error)
}

type Mysql

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

func NewMysql

func NewMysql() *Mysql

func NewSharding added in v0.0.2

func NewSharding(database *sql.DB) *Mysql

func (*Mysql) BatchInsert

func (m *Mysql) BatchInsert(batch *ds.Batch) (int64, error)

func (*Mysql) Begin

func (m *Mysql) Begin() error

func (*Mysql) Commit

func (m *Mysql) Commit() error

func (*Mysql) Delete

func (m *Mysql) Delete(del *ds.Delete) (int64, error)

func (*Mysql) Exec

func (m *Mysql) Exec(statement string) error

func (*Mysql) FetchAll

func (m *Mysql) FetchAll(table string, where map[string]interface{}, t interface{}) ([]interface{}, error)

func (*Mysql) FetchAllByWhere added in v0.0.6

func (m *Mysql) FetchAllByWhere(table string, where *ds.Where, t interface{}) ([]interface{}, error)

func (*Mysql) FetchPage added in v0.0.6

func (m *Mysql) FetchPage(table string, where map[string]interface{}, t interface{}, page int, pageSize int) ([]interface{}, error)

func (*Mysql) FetchPageByWhere added in v0.0.6

func (m *Mysql) FetchPageByWhere(table string, where *ds.Where, t interface{}, page int, pageSize int) ([]interface{}, error)

func (*Mysql) FetchRow

func (m *Mysql) FetchRow(table string, where map[string]interface{}, t interface{}) (interface{}, error)

func (*Mysql) InTransaction

func (m *Mysql) InTransaction() bool

func (*Mysql) Insert

func (m *Mysql) Insert(insert *ds.Insert) (int64, error)

func (*Mysql) Query

func (m *Mysql) Query(query string, t interface{}, args ...interface{}) ([]interface{}, error)

func (*Mysql) RollBack

func (m *Mysql) RollBack() error

func (*Mysql) Select

func (m *Mysql) Select(sel *ds.Select, t interface{}) ([]interface{}, error)

func (*Mysql) Update

func (m *Mysql) Update(update *ds.Update) (int64, error)

Jump to

Keyboard shortcuts

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