dbutil

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2019 License: MIT Imports: 14 Imported by: 0

README

dbutil

db opt for sqlx

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cfg = struct {
	Limit int
}{
	Limit: 1000,
}
View Source
var ErrTag = struct {
	DbCreateError    string `toml:"db_create_error"`
	DbDeleteError    string `toml:"db_delete_error"`
	DbUpdateError    string `toml:"db_update_error"`
	DbCountError     string `toml:"db_count_error"`
	DbGetError       string `toml:"db_get_error"`
	DbDeleteOneError string `toml:"db_delete_one_error"`
	DbUpdateOneError string `toml:"db_update_one_error"`
	DbGetOneError    string `toml:"db_get_one_error"`
}{
	DbCreateError:    "db_create_error",
	DbDeleteError:    "db_delete_error",
	DbUpdateError:    "db_update_error",
	DbCountError:     "db_count_error",
	DbGetError:       "db_get_error",
	DbDeleteOneError: "db_delete_one_error",
	DbUpdateOneError: "db_update_one_error",
	DbGetOneError:    "db_get_one_error",
}

Functions

func CopyStruct added in v0.0.2

func CopyStruct(src, dst interface{})

func Struct2Map added in v0.0.2

func Struct2Map(obj interface{}) map[string]interface{}

func ToFloat

func ToFloat(p string) float64

func ToInt

func ToInt(p string) int

Types

type DbUtil

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

func Default

func Default() *DbUtil

func (*DbUtil) DbColT added in v0.0.2

func (t *DbUtil) DbColT() map[string]map[string]map[string]string

func (*DbUtil) DbConfigAdd added in v0.0.2

func (t *DbUtil) DbConfigAdd(name string, cfg *gosql.Config)

func (*DbUtil) DbConfigDelete added in v0.0.2

func (t *DbUtil) DbConfigDelete(name string)

func (*DbUtil) DbConfigUpdate added in v0.0.2

func (t *DbUtil) DbConfigUpdate(name string, cfg *gosql.Config)

func (*DbUtil) DbConnect added in v0.0.2

func (t *DbUtil) DbConnect()

func (*DbUtil) DbStats added in v0.0.2

func (t *DbUtil) DbStats() (stats map[string]sql.DBStats)

func (*DbUtil) Model added in v0.0.2

func (t *DbUtil) Model(m gosql.IModel) *_model

func (*DbUtil) ResCount added in v0.0.2

func (t *DbUtil) ResCount(dbName, tbName string, filter ...interface{}) int64

func (*DbUtil) ResCreateMany added in v0.0.2

func (t *DbUtil) ResCreateMany(dbName, tbName string, dts ...map[string]interface{}) (lastInsertId int64)

创建记录

func (*DbUtil) ResDeleteMany added in v0.0.2

func (t *DbUtil) ResDeleteMany(dbName, tbName string, filter ...interface{}) int64

删除记录

func (*DbUtil) ResDeleteOne added in v0.0.2

func (t *DbUtil) ResDeleteOne(dbName, tbName string, id int) int64

func (*DbUtil) ResGetAll added in v0.0.2

func (t *DbUtil) ResGetAll(dbName, tbName string) []map[string]interface{}

func (*DbUtil) ResGetMany added in v0.0.2

func (t *DbUtil) ResGetMany(dbName, tbName string, fields string, groupBy string, order string, limit, offset int, filter ...interface{}) []map[string]interface{}

查询

func (*DbUtil) ResGetOne added in v0.0.2

func (t *DbUtil) ResGetOne(dbName, tbName string, id int) map[string]interface{}

func (*DbUtil) ResPage added in v0.0.2

func (t *DbUtil) ResPage(dbName, tbName string, fields string, order string, limit, offset int, filter ...interface{}) []map[string]interface{}

func (*DbUtil) ResUpdateMany added in v0.0.2

func (t *DbUtil) ResUpdateMany(dbName, tbName string, data map[string]interface{}, filter ...interface{}) int64

修改记录

func (*DbUtil) ResUpdateOne added in v0.0.2

func (t *DbUtil) ResUpdateOne(dbName, tbName string, id int, dt map[string]interface{}) int64

Jump to

Keyboard shortcuts

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