restorm

package
v0.2.55 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Errs = struct {
	DbCreateError    string
	DbDeleteError    string
	DbUpdateError    string
	DbCountError     string
	DbGetError       string
	DbDeleteOneError string
	DbUpdateOneError string
	DbGetOneError    string
}{
	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 Converter

func Converter(sqlType string) func(interface{}) interface{}

Converter 转换

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) ColTs

func (t *RestOrm) ColTs() map[string]map[string]map[string]string

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) (err error)

func (*RestOrm) DbStats

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

func (*RestOrm) DbUpdate

func (t *RestOrm) DbUpdate(name string) (err error)

func (*RestOrm) Import

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

Import SQL DDL from sql file

func (*RestOrm) ResCount

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

func (*RestOrm) ResCreateMany

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

创建记录

func (*RestOrm) ResDeleteMany

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

删除记录

func (*RestOrm) ResGetMany

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

查询

func (*RestOrm) ResUpdateMany

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

修改记录

Jump to

Keyboard shortcuts

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