dao

package
v0.0.0-...-e53cabd Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert       = "Insert"
	InsertIgnore = "Insert Ignore"
	Replace      = "Replace"
)

objects insert ways

Variables

View Source
var EmptyCond = CondFunc(func(Cond) {})

EmptyCond 空过滤条件

Functions

func Exec

func Exec(ctx context.Context, db Executor, expr string, args ...interface{}) (sql.Result, error)

Exec 执行 SQL

func ExecB

func ExecB(ctx context.Context, db Executor, b sqlbuilder.Builder) (sql.Result, error)

ExecB 执行 SQL

func GetBool

func GetBool(ctx context.Context, db Executor, b sqlbuilder.Builder) (bool, error)

GetBool 查询单个 bool

func GetCount

func GetCount(ctx context.Context, db Executor, b sqlbuilder.Builder) (int64, error)

GetCount 使用相同查询条件获取查询的总数

func GetFloat64

func GetFloat64(ctx context.Context, db Executor, b sqlbuilder.Builder) (float64, error)

GetFloat64 查询单个 float64

func GetInt

func GetInt(ctx context.Context, db Executor, b sqlbuilder.Builder) (int, error)

GetInt 查询单个 int

func GetInt64

func GetInt64(ctx context.Context, db Executor, b sqlbuilder.Builder) (int64, error)

GetInt64 查询单个 int64

func GetString

func GetString(ctx context.Context, db Executor, b sqlbuilder.Builder) (string, error)

GetString 查询单个 string

func GetStruct

func GetStruct(ctx context.Context, db Executor, out interface{}, b sqlbuilder.Builder) error

GetStruct 查询单个结构体

func GetTagStruct

func GetTagStruct(ctx context.Context, db Executor, tag string, out interface{}, b sqlbuilder.Builder) error

GetTagStruct 查询单个结构体

func PullBools

func PullBools(ctx context.Context, db Executor, b sqlbuilder.Builder) ([]bool, error)

PullBools 查询单列 bool

func PullFloat64s

func PullFloat64s(ctx context.Context, db Executor, b sqlbuilder.Builder) ([]float64, error)

PullFloat64s 查询单列 float64

func PullInt64s

func PullInt64s(ctx context.Context, db Executor, b sqlbuilder.Builder) ([]int64, error)

PullInt64s 查询单列 int64

func PullInts

func PullInts(ctx context.Context, db Executor, b sqlbuilder.Builder) ([]int, error)

PullInts 查询单列 int

func PullStrings

func PullStrings(ctx context.Context, db Executor, b sqlbuilder.Builder) ([]string, error)

PullStrings 查询单列字符串

func PullStructs

func PullStructs(ctx context.Context, db Executor, out interface{}, b sqlbuilder.Builder) error

PullStructs 查询结构体slice

func PullTagStructs

func PullTagStructs(ctx context.Context, db Executor, tag string, out interface{}, b sqlbuilder.Builder) error

PullTagStructs 查询结构体slice

func Query

func Query(ctx context.Context, db Executor, expr string, args ...interface{}) (*sql.Rows, error)

Query 执行查询

func QueryB

func QueryB(ctx context.Context, db Executor, b sqlbuilder.Builder) (*sql.Rows, error)

QueryB 执行查询

func QueryRow

func QueryRow(ctx context.Context, db Executor, expr string, args ...interface{}) *sql.Row

QueryRow 执行查询

func QueryRowB

func QueryRowB(ctx context.Context, db Executor, b sqlbuilder.Builder) *sql.Row

QueryRowB 执行查询

func TxWrapper

func TxWrapper(ctx context.Context, db *sql.DB, opts *sql.TxOptions, callback TxCallback) error

TxWrapper 事务代码的帮助函数

Types

type Cond

type Cond = *sqlbuilder.SelectBuilder

sqlbuilder condition

type CondFunc

type CondFunc func(Cond)

sqlbuilder condition

type DelCond

type DelCond = *sqlbuilder.DeleteBuilder

sqlbuilder condition

type DelCondFunc

type DelCondFunc func(DelCond)

sqlbuilder condition

type Executor

type Executor interface {
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

Executor is an *sql.DB or *sql.Tx or even *sql.Conn

type Struct

type Struct struct {
	*sqlbuilder.Struct
	// contains filtered or unexported fields
}

Struct 对 sqlbuilder.Struct 进行了封装,使其更易使用

func S

func S(val interface{}) *Struct

S ...

func (*Struct) Exec

func (s *Struct) Exec(ctx context.Context, db Executor, expr string, args ...interface{}) (sql.Result, error)

Exec ...

func (*Struct) ExecB

func (s *Struct) ExecB(ctx context.Context, db Executor, b sqlbuilder.Builder) (sql.Result, error)

ExecB ...

func (*Struct) Query

func (s *Struct) Query(ctx context.Context, db Executor, result interface{}, expr string, args ...interface{}) error

Query ...

func (*Struct) QueryB

func (s *Struct) QueryB(ctx context.Context, db Executor, result interface{}, b sqlbuilder.Builder) error

QueryB ...

func (*Struct) QueryRow

func (s *Struct) QueryRow(
	ctx context.Context, db Executor, result interface{}, expr string, args ...interface{},
) error

QueryRow ...

func (*Struct) QueryRowB

func (s *Struct) QueryRowB(ctx context.Context, db Executor, result interface{}, b sqlbuilder.Builder) error

QueryRowB ...

func (*Struct) TagQuery

func (s *Struct) TagQuery(
	ctx context.Context, db Executor, result interface{}, tag, expr string, args ...interface{},
) error

TagQuery ...

func (*Struct) TagQueryB

func (s *Struct) TagQueryB(
	ctx context.Context, db Executor, result interface{}, tag string, b sqlbuilder.Builder,
) error

TagQueryB ...

func (*Struct) TagQueryRow

func (s *Struct) TagQueryRow(
	ctx context.Context, db Executor, result interface{}, tag, expr string, args ...interface{},
) error

TagQueryRow ...

func (*Struct) TagQueryRowB

func (s *Struct) TagQueryRowB(
	ctx context.Context, db Executor, result interface{}, tag string, b sqlbuilder.Builder,
) error

TagQueryRowB ...

type TxCallback

type TxCallback func(ctx context.Context, tx *sql.Tx) error

TxCallback 事务回调

type UpdateCond

type UpdateCond = *sqlbuilder.UpdateBuilder

sqlbuilder condition

type UpdateCondFunc

type UpdateCondFunc func(UpdateCond)

sqlbuilder condition

Jump to

Keyboard shortcuts

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