restorm

package
v0.0.0-...-fb5a763 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTag = 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",
}

ErrTag is error tags

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_left_time" json:"max_left_time"`
	ShowSQL      bool   `toml:"show_sql" json:"show_sql"`
	// contains filtered or unexported fields
}

Config is database connection configuration

type IRestOrm

type IRestOrm interface {
	// DbAdd 添加数据库配置,并获取表字段和类型结构
	// dbName 数据库别名,最好是数据库的名字
	// cfg 配置文件
	DbAdd(dbName string, cfg *Config)

	// DbDelete 删除数据库配置,暂停数据库连接以及删除表字段和类型
	DbDelete(dbName string)

	// DbUpdate 更新数据库配置,更新表字段以及类型或者更新数据库连接
	DbUpdate(dbName string, cfg *Config)

	// ResCreateMany 批量添加记录
	// dbName 数据库名称或者添加配置文件时的别名
	// tbName 数据库表名称
	ResCreateMany(dbName, tbName string, dts ...map[string]interface{}) (err error)

	// ResDeleteMany 批量删除记录
	ResDeleteMany(dbName, tbName string, where ...interface{}) (err error)

	// ResUpdateMany 根据过滤修改记录
	ResUpdateMany(dbName, tbName string, data map[string]interface{}, where ...interface{}) (err error)

	// ResCount 根据过滤统计查询信息
	// where 数据库过滤条件
	ResCount(dbName, tbName string, where ...interface{}) (c int64, err error)

	// ResGetMany 根据过滤统计查询信息
	// fields 查询的字段信息
	// groupBy 分组字段
	// order 排序字段
	// limit 查询后的限制数量
	// offset 偏移量
	// where 数据库过滤条件
	ResGetMany(dbName, tbName string, fields string, groupBy string, order string, limit, offset string, where ...interface{}) (dts []map[string]interface{}, err error)

	// DbStats 获取数据库连接状态
	DbStats() map[string]sql.DBStats
}

IRestOrm is Restorm interface

func Default

func Default() IRestOrm

Default is default RestOrm instance

Jump to

Keyboard shortcuts

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