sqler

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TagName = "sqler"

Variables

This section is empty.

Functions

func IsNotFoundError added in v0.1.1

func IsNotFoundError(err error) bool

func Mapping added in v0.1.1

func Mapping(data interface{}) map[string]interface{}

Mapping 将结构体转换成 map

func Scan

func Scan(rs *sql.Rows, target interface{}) error

func ScanToMap added in v0.1.1

func ScanToMap(rs *sql.Rows) ([]map[string]interface{}, error)

ScanToMap 将 SQL 查询结构 序列化到一个 map 中

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(ops Options) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

Close 关闭数据库连接

func (*DB) Count added in v0.1.1

func (db *DB) Count(name string, where Where, col string) (int64, error)

func (*DB) Delete added in v0.1.1

func (db *DB) Delete(name string, where Where) (int64, error)

func (*DB) Insert added in v0.1.1

func (db *DB) Insert(name string, data map[string]interface{}) (int64, error)

func (*DB) Modify added in v0.1.1

func (db *DB) Modify(name string, where Where, update map[string]interface{}) (int64, error)

func (*DB) MultiInsert added in v0.1.1

func (db *DB) MultiInsert(name string, data []map[string]interface{}) (int64, error)

func (*DB) Select added in v0.1.1

func (db *DB) Select(name string, where Where, fields Fields) *Fruit

type Fields added in v0.1.1

type Fields []string

type Fruit added in v0.1.1

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

func (*Fruit) Close added in v0.1.1

func (rs *Fruit) Close()

func (*Fruit) ConvertTo added in v0.1.1

func (rs *Fruit) ConvertTo(target interface{}) error

func (*Fruit) ConvertToMap added in v0.1.1

func (rs *Fruit) ConvertToMap() ([]map[string]interface{}, error)

func (*Fruit) Error added in v0.1.1

func (rs *Fruit) Error() error

func (*Fruit) Rows added in v0.1.1

func (rs *Fruit) Rows() *sql.Rows

type Options

type Options struct {
	Driver  string `yaml:"driver" mapstructure:"driver"`
	ConnStr string `yaml:"dsn" mapstructure:"dsn"`
	// 定时保活
	KeepAlive int `yaml:"keep_alive" mapstructure:"keep_alive"`
	// 最大可空闲连接数量
	MaxIdles int `yaml:"max_idles" mapstructure:"max_idles"`
	// 最大连接数量
	MaxOpens    int `yaml:"max_opens" mapstructure:"max_opens"`
	MaxLifeTime int `yaml:"max_life_time" mapstructure:"max_life_time"`
}

type Where added in v0.1.1

type Where map[string]interface{}

Jump to

Keyboard shortcuts

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