sqler

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MappingField

func MappingField(source reflect.Type) map[string]*Field

func SetContainer

func SetContainer(fields map[string]*Field, column []string) []interface{}

Types

type DB

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

func NewDB

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

func (*DB) Begin

func (db *DB) Begin() (*TX, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Do

func (db *DB) Do(sqlStr string) *SqlResult

EXEC Sql

func (*DB) Fetch

func (db *DB) Fetch(sqlStr string) *Rows

func (*DB) Pluck

func (db *DB) Pluck(sqlStr string) *Rows

func (*DB) Scale

func (db *DB) Scale(sqlStr string) *Rows

func (*DB) Select

func (db *DB) Select(sqlStr string) *Rows

type DBOptions

type DBOptions struct {
	ConnStr   string `json:"conn_str" mapstructure:"conn_str" yaml:"conn_str"`
	Driver    string `json:"driver" mapstructure:"driver" yaml:"driver"`
	KeepAlive int    `json:"keep_alive" mapstructure:"keep_alive" yaml:"keep_alive"`
	MaxIdles  int    `json:"max_idles" mapstructure:"max_idles" yaml:"max_idles"`
	MaxOpens  int    `json:"max_opens" mapstructure:"max_opens" yaml:"max_opens"`
}

type Field

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

type Rows

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

func (*Rows) ConvertTo

func (rs *Rows) ConvertTo(out interface{}) error

func (*Rows) Get

func (rs *Rows) Get(out interface{}) error

type SqlResult

type SqlResult struct {
	Error        error `json:"error"`
	LastInsertId int64 `json:"last_insert_id"`
	RowsAffected int64 `json:"rows_affected"`
}

type TX

type TX struct {
	*sql.Tx
}

func (*TX) Commit

func (tx *TX) Commit() error

func (*TX) Do

func (tx *TX) Do(sqlStr string) *SqlResult

func (*TX) Fetch

func (tx *TX) Fetch(sqlStr string) *Rows

func (*TX) Pluck

func (tx *TX) Pluck(sqlStr string) *Rows

func (*TX) Rollback

func (tx *TX) Rollback() error

func (*TX) Scale

func (tx *TX) Scale(sqlStr string) *Rows

func (*TX) Select

func (tx *TX) Select(sqlStr string) *Rows

Jump to

Keyboard shortcuts

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