sqlimpl

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(db Execable, sql string, retAffect bool, params ...interface{}) (int64, error)

func QueryMany

func QueryMany(db Queryable, sql string, handler HandleFunc, params ...interface{}) error

QueryMany 执行sql查询, 返回多行. 每行都会调用一次handler函数

func QueryOne

func QueryOne(db Queryable, sql string, handler HandleFunc, params ...interface{}) error

QueryOne 执行sql查询,返回一行. 会使用返回的一行数据调用一次 handler函数

Types

type Execable

type Execable interface {
	Exec(sql string, vs ...interface{}) (sql.Result, error)
}

Execable 定义可以进行sql执行的接口. 以接受可以进行sql执行的对象 *sql.DB, *sql.Tx等

type HandleFunc

type HandleFunc func(*sql.Rows) error

HandleFunc 查询时每行都会调用这个方法,一般通过闭包来对需要返回 的ORM对象进行赋值.

type Queryable

type Queryable interface {
	Query(sql string, vs ...interface{}) (*sql.Rows, error)
}

Queryable 定义可以进行sql查询的接口. 以接收任何sql查询对象, 例如 *sql.DB,*sql.Tx,或是自定义的sql对象

Jump to

Keyboard shortcuts

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