internal

package
v0.0.0-...-09cbfc4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enable       bool   `toml:"enable" json:"enable"`
	Driver       string `toml:"driver" json:"driver"`
	Dsn          string `toml:"dsn" json:"dsn"`
	MaxOpenConns int    `toml:"max_open_conns" json:"max_open_conns"`
	MaxIdleConns int    `toml:"max_idle_conns" json:"max_idle_conns"`
	MaxLifetime  int    `toml:"max_lefttime" json:"max_lefttime"`
	ShowSql      bool   `toml:"show_sql" json:"show_sql"`
	// contains filtered or unexported fields
}

Config is database connection configuration

type RestOrm

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

func Default

func Default() *RestOrm

func (*RestOrm) DbConfigAdd

func (t *RestOrm) DbConfigAdd(name string, cfg *Config)

func (*RestOrm) DbConfigDelete

func (t *RestOrm) DbConfigDelete(name string)

func (*RestOrm) DbConfigUpdate

func (t *RestOrm) DbConfigUpdate(name string, cfg *Config)

func (*RestOrm) DbStats

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

func (*RestOrm) Import

func (t *RestOrm) Import(name string, f io.Reader) []sql.Result

Import SQL DDL from sql file

func (*RestOrm) ResCount

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

func (*RestOrm) ResCreateMany

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

创建记录

func (*RestOrm) ResDeleteMany

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

删除记录

func (*RestOrm) ResDeleteOne

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

func (*RestOrm) ResGetAll

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

func (*RestOrm) ResGetMany

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

查询

func (*RestOrm) ResGetOne

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

func (*RestOrm) ResPage

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

func (*RestOrm) ResUpdateMany

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

修改记录

func (*RestOrm) ResUpdateOne

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

type RestOrmDef

type RestOrmDef interface {
	ResCreateMany(dbName, tbName string, dts ...map[string]interface{}) (lastInsertId int64)
	ResDeleteMany(dbName, tbName string, filter ...interface{}) int64
	ResUpdateMany(dbName, tbName string, data map[string]interface{}, filter ...interface{}) int64
	ResGetMany(dbName, tbName string, fields string, groupBy string, order string, limit, offset int, filter ...interface{}) []map[string]interface{}
	ResPage(dbName, tbName string, fields string, order string, limit, offset int, filter ...interface{}) []map[string]interface{}
	ResCount(dbName, tbName string, filter ...interface{}) int64

	WithTx(tx *sqlx.Tx)
	Hint(hint string)
	ForceIndex(i string)

	ResQuery(dbName string, sql string) (lastInsertId int64)
	ResExec(dbName string, sql string) (lastInsertId int64)
}

type SQLBuilder

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

func (*SQLBuilder) Where

func (s *SQLBuilder) Where(str string, args ...interface{})

Jump to

Keyboard shortcuts

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