query

package
v3.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BETWEEN    = "BETWEEN"
	NOTBETWEEN = "NOT BETWEEN"
	IN         = "IN"
	NOTIN      = "NOT IN"
	AND        = "AND"
	OR         = "OR"
	ISNULL     = "IS NULL"
	ISNOTNULL  = "IS NOT NULL"
	EQUAL      = "="
	NOTEQUAL   = "!="
	LIKE       = "LIKE"
	JOIN       = "JOIN"
	INNERJOIN  = "INNER JOIN"
	LEFTJOIN   = "LEFT JOIN"
	RIGHTJOIN  = "RIGHT JOIN"
	UNION      = "UNION"
	UNIONALL   = "UNION ALL"
	DESC       = "DESC"
	ASC        = "ASC"
)

BETWEEN ...

Variables

This section is empty.

Functions

func NewSQLConn added in v3.1.7

func NewSQLConn(driverName, server string, opt *Opt) (*sql.DB, error)

NewSQLConn ...

Types

type BatchError

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

A BatchError is an error that can hold multiple errors.

func (*BatchError) Add

func (be *BatchError) Add(err error)

Add adds err to be.

func (*BatchError) Err

func (be *BatchError) Err() error

Err returns an error that represents all errors.

func (*BatchError) NotNil

func (be *BatchError) NotNil() bool

NotNil checks if any error inside.

type Builder added in v3.1.9

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

Builder 查询构造器

func (*Builder) Between added in v3.1.9

func (builder *Builder) Between(column string, value1 interface{}, value2 interface{}) *Builder

Between 构造Between

func (*Builder) Count added in v3.1.9

func (builder *Builder) Count() (int64, error)

Count ...

func (*Builder) Delete added in v3.1.9

func (builder *Builder) Delete() (int64, error)

Delete .

func (*Builder) DeleteSQL added in v3.1.9

func (builder *Builder) DeleteSQL() string

DeleteSQL .

func (*Builder) Distinct added in v3.1.9

func (builder *Builder) Distinct() *Builder

Distinct .

func (*Builder) Equal added in v3.1.9

func (builder *Builder) Equal(column string, value interface{}) *Builder

Equal 构造等于

func (*Builder) Exec added in v3.1.9

func (builder *Builder) Exec(sql string, args ...interface{}) (int64, error)

Exec 原始SQl语句执行

func (*Builder) ExecSQL added in v3.1.9

func (builder *Builder) ExecSQL(sql string, args ...interface{}) string

ExecSQL 原始SQl语句执行

func (*Builder) GroupBy added in v3.1.9

func (builder *Builder) GroupBy(groups ...string) *Builder

GroupBy .

func (*Builder) In added in v3.1.9

func (builder *Builder) In(column string, value ...interface{}) *Builder

In 构造 in语句

func (*Builder) InnerJoin added in v3.1.9

func (builder *Builder) InnerJoin(tablename string, on string) *Builder

InnerJoin ...

func (*Builder) Insert added in v3.1.9

func (builder *Builder) Insert(data interface{}) (int64, error)

Insert 插入数据

func (*Builder) InsertSQL added in v3.1.9

func (builder *Builder) InsertSQL(data interface{}) string

InsertSQL 获取SQL语句

func (*Builder) InsertUpdate added in v3.1.9

func (builder *Builder) InsertUpdate(insert interface{}, update interface{}) (int64, error)

InsertUpdate ...

func (*Builder) InsertUpdateSQL added in v3.1.9

func (builder *Builder) InsertUpdateSQL(insert interface{}, update interface{}) string

InsertUpdateSQL ...

func (*Builder) IsNULL added in v3.1.9

func (builder *Builder) IsNULL(column string) *Builder

IsNULL .

func (*Builder) IsNotNULL added in v3.1.9

func (builder *Builder) IsNotNULL(column string) *Builder

IsNotNULL .

func (*Builder) IsZero added in v3.1.9

func (builder *Builder) IsZero(v reflect.Value) bool

IsZero ...

func (*Builder) Join added in v3.1.9

func (builder *Builder) Join(tablename string, on string) *Builder

Join .

func (*Builder) LeftJoin added in v3.1.9

func (builder *Builder) LeftJoin(tablename string, on string) *Builder

LeftJoin .

func (*Builder) Like added in v3.1.9

func (builder *Builder) Like(column string, value interface{}) *Builder

Like .

func (*Builder) Limit added in v3.1.9

func (builder *Builder) Limit(limit int64) *Builder

Limit .

func (*Builder) MultiInsert added in v3.1.9

func (builder *Builder) MultiInsert(datas ...interface{}) (int64, error)

MultiInsert 批量插入

func (*Builder) MultiInsertSQL added in v3.1.9

func (builder *Builder) MultiInsertSQL(datas ...interface{}) string

MultiInsertSQL 批量插入

func (*Builder) NotBetween added in v3.1.9

func (builder *Builder) NotBetween(column string, value1 interface{}, value2 interface{}) *Builder

NotBetween 构造不Not Between

func (*Builder) NotEqual added in v3.1.9

func (builder *Builder) NotEqual(column string, value interface{}) *Builder

NotEqual 构造不等于

func (*Builder) NotIn added in v3.1.9

func (builder *Builder) NotIn(column string, value ...interface{}) *Builder

NotIn .

func (*Builder) NotOrBetween added in v3.1.9

func (builder *Builder) NotOrBetween(column string, value1 interface{}, value2 interface{}) *Builder

NotOrBetween 构造 Not Between OR Not Between

func (*Builder) Offset added in v3.1.9

func (builder *Builder) Offset(offset int64) *Builder

Offset .

func (*Builder) OrBetween added in v3.1.9

func (builder *Builder) OrBetween(column string, value1 interface{}, value2 interface{}) *Builder

OrBetween 构造 或者 Between

func (*Builder) OrEqual added in v3.1.9

func (builder *Builder) OrEqual(column string, value interface{}) *Builder

OrEqual 构造或者等于

func (*Builder) OrIn added in v3.1.9

func (builder *Builder) OrIn(column string, value ...interface{}) *Builder

OrIn orin语句

func (*Builder) OrIsNULL added in v3.1.9

func (builder *Builder) OrIsNULL(column string) *Builder

OrIsNULL .

func (*Builder) OrIsNotNULL added in v3.1.9

func (builder *Builder) OrIsNotNULL(column string) *Builder

OrIsNotNULL .

func (*Builder) OrLike added in v3.1.9

func (builder *Builder) OrLike(column string, value interface{}) *Builder

OrLike .

func (*Builder) OrNotEqual added in v3.1.9

func (builder *Builder) OrNotEqual(column string, value interface{}) *Builder

OrNotEqual 构造或者不等于

func (*Builder) OrNotIn added in v3.1.9

func (builder *Builder) OrNotIn(column string, value ...interface{}) *Builder

OrNotIn .

func (*Builder) OrWhere added in v3.1.9

func (builder *Builder) OrWhere(column string, value ...interface{}) *Builder

OrWhere 构造OR条件

func (*Builder) OrderBy added in v3.1.9

func (builder *Builder) OrderBy(column string, direction string) *Builder

OrderBy .

func (*Builder) QueryRow added in v3.1.9

func (builder *Builder) QueryRow(sql string, args ...interface{}) *Row

QueryRow ...

func (*Builder) QueryRowSQL added in v3.1.9

func (builder *Builder) QueryRowSQL(sql string, args ...interface{}) string

QueryRowSQL ...

func (*Builder) QueryRows added in v3.1.9

func (builder *Builder) QueryRows(sql string, args ...interface{}) *Rows

QueryRows ...

func (*Builder) QueryRowsSQL added in v3.1.9

func (builder *Builder) QueryRowsSQL(sql string, args ...interface{}) string

QueryRowsSQL ...

func (*Builder) Replace added in v3.1.9

func (builder *Builder) Replace(datas ...interface{}) (int64, error)

Replace 替换

func (*Builder) ReplaceSQL added in v3.1.9

func (builder *Builder) ReplaceSQL(datas ...interface{}) string

ReplaceSQL 替换

func (*Builder) RightJoin added in v3.1.9

func (builder *Builder) RightJoin(tablename string, on string) *Builder

RightJoin .

func (*Builder) Row added in v3.1.9

func (builder *Builder) Row() *Row

Row 获取一条记录

func (*Builder) RowSQL added in v3.1.9

func (builder *Builder) RowSQL() string

RowSQL ...

func (*Builder) Rows added in v3.1.9

func (builder *Builder) Rows() *Rows

Rows 获取多条记录

func (*Builder) RowsSQL added in v3.1.9

func (builder *Builder) RowsSQL() string

RowsSQL ...

func (*Builder) Select added in v3.1.9

func (builder *Builder) Select(columns ...string) *Builder

Select 查询字段

func (*Builder) Skip added in v3.1.9

func (builder *Builder) Skip(offset int64) *Builder

Skip .

func (*Builder) Table added in v3.1.9

func (builder *Builder) Table(tableName ...string) *Builder

Table 设置操作的表名称

func (*Builder) ToSQL added in v3.1.9

func (builder *Builder) ToSQL(method string) string

ToSQL 输出SQL语句

func (*Builder) Union added in v3.1.9

func (builder *Builder) Union(unions ...Builder) *Builder

Union .

func (*Builder) UnionAll added in v3.1.9

func (builder *Builder) UnionAll(unions ...Builder) *Builder

UnionAll .

func (*Builder) UnionLimit added in v3.1.9

func (builder *Builder) UnionLimit(limit int64) *Builder

UnionLimit .

func (*Builder) UnionOffset added in v3.1.9

func (builder *Builder) UnionOffset(offset int64) *Builder

UnionOffset .

func (*Builder) UnionOrderBy added in v3.1.9

func (builder *Builder) UnionOrderBy(column string, direction string) *Builder

UnionOrderBy .

func (*Builder) Update added in v3.1.9

func (builder *Builder) Update(data interface{}) (int64, error)

Update 更新

func (*Builder) UpdateSQL added in v3.1.9

func (builder *Builder) UpdateSQL(data interface{}) string

UpdateSQL 更新

func (*Builder) Where added in v3.1.9

func (builder *Builder) Where(column string, value ...interface{}) *Builder

Where 构造条件语句

type Connection

type Connection interface {
	Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error)
	Query(ctx context.Context, querySQL string, args ...interface{}) (*sql.Rows, error)
	NewBuilder(ctx context.Context) *Builder
	SQLRaw() string
	LastSQL(querySQL string, args ...interface{})
}

Connection 链接

type Epr

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

Epr ...

func NewEpr

func NewEpr(value string) Epr

NewEpr ...

func (Epr) ToString

func (e Epr) ToString() string

ToString ...

type Grammar

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

Grammar sql 语法

func (Grammar) Delete

func (g Grammar) Delete() string

Delete ...

func (Grammar) Insert

func (g Grammar) Insert() string

Insert ...

func (Grammar) InsertUpdate

func (g Grammar) InsertUpdate() string

InsertUpdate ...

func (Grammar) Replace

func (g Grammar) Replace() string

Replace ...

func (Grammar) Select

func (g Grammar) Select() string

Select 构造select

func (Grammar) ToSQL added in v3.1.8

func (g Grammar) ToSQL() string

ToSQL ...

func (Grammar) Update

func (g Grammar) Update() string

Update ...

type NullBool

type NullBool struct{ sql.NullBool }

NullBool ...

func NewBool

func NewBool(b bool) NullBool

NewBool ...

func NewNullBool

func NewNullBool() NullBool

NewNullBool ...

func (NullBool) Convert

func (nb NullBool) Convert() string

Convert ...

func (NullBool) IsEmpty

func (nb NullBool) IsEmpty() bool

IsEmpty ...

func (NullBool) IsValid

func (nb NullBool) IsValid() bool

IsValid ...

func (NullBool) MarshalJSON

func (nb NullBool) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullBool) Result

func (nb NullBool) Result() interface{}

Result ...

func (*NullBool) UnmarshalJSON

func (nb *NullBool) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullDate

type NullDate struct {
	sql.NullString
}

NullDate 空字符串

func NewDate

func NewDate(s interface{}) NullDate

NewDate ...

func NewNullDate

func NewNullDate() NullDate

NewNullDate ...

func (NullDate) IsEmpty

func (nt NullDate) IsEmpty() bool

IsEmpty ...

func (NullDate) IsValid

func (nt NullDate) IsValid() bool

IsValid ...

func (NullDate) MarshalJSON

func (nt NullDate) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullDate) Result

func (nt NullDate) Result() interface{}

Result ...

func (*NullDate) Scan

func (nt *NullDate) Scan(value interface{}) error

Scan ...

func (*NullDate) UnmarshalJSON

func (nt *NullDate) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullDateTime

type NullDateTime struct {
	sql.NullString
}

NullDateTime NullDate 空字符串

func NewDateTime

func NewDateTime(s interface{}) NullDateTime

NewDateTime ...

func NewNullDateTime

func NewNullDateTime() NullDateTime

NewNullDateTime ...

func (NullDateTime) IsEmpty

func (nt NullDateTime) IsEmpty() bool

IsEmpty ...

func (NullDateTime) IsValid

func (nt NullDateTime) IsValid() bool

IsValid ...

func (NullDateTime) MarshalJSON

func (nt NullDateTime) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullDateTime) Result

func (nt NullDateTime) Result() interface{}

Result ...

func (*NullDateTime) Scan

func (nt *NullDateTime) Scan(value interface{}) error

Scan ...

func (*NullDateTime) UnmarshalJSON

func (nt *NullDateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullFloat64

type NullFloat64 struct{ sql.NullFloat64 }

NullFloat64 ...

func NewFloat64

func NewFloat64(f float64) NullFloat64

NewFloat64 ...

func NewNullFloat64

func NewNullFloat64() NullFloat64

NewNullFloat64 ...

func (NullFloat64) Convert

func (nf NullFloat64) Convert() string

Convert ...

func (NullFloat64) IsEmpty

func (nf NullFloat64) IsEmpty() bool

IsEmpty ...

func (NullFloat64) IsValid

func (nf NullFloat64) IsValid() bool

IsValid ...

func (NullFloat64) MarshalJSON

func (nf NullFloat64) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullFloat64) Result

func (nf NullFloat64) Result() interface{}

Result ...

func (*NullFloat64) UnmarshalJSON

func (nf *NullFloat64) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullInt32

type NullInt32 struct{ sql.NullInt32 }

NullInt32 ...

func NewInt32

func NewInt32(i int32) NullInt32

NewInt32 ...

func NewNullInt32

func NewNullInt32() NullInt32

NewNullInt32 ...

func (NullInt32) Convert

func (ni NullInt32) Convert() string

Convert ...

func (NullInt32) IsEmpty

func (ni NullInt32) IsEmpty() bool

IsEmpty ...

func (NullInt32) IsValid

func (ni NullInt32) IsValid() bool

IsValid ...

func (NullInt32) MarshalJSON

func (ni NullInt32) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullInt32) Result

func (ni NullInt32) Result() interface{}

Result ...

func (*NullInt32) UnmarshalJSON

func (ni *NullInt32) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullInt64

type NullInt64 struct{ sql.NullInt64 }

NullInt64 ...

func NewInt64

func NewInt64(i int64) NullInt64

NewInt64 ...

func NewNullInt64

func NewNullInt64() NullInt64

NewNullInt64 ...

func (NullInt64) Convert

func (ni NullInt64) Convert() string

Convert ...

func (NullInt64) IsEmpty

func (ni NullInt64) IsEmpty() bool

IsEmpty ...

func (NullInt64) IsValid

func (ni NullInt64) IsValid() bool

IsValid ...

func (NullInt64) MarshalJSON

func (ni NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullInt64) Result

func (ni NullInt64) Result() interface{}

Result ...

func (*NullInt64) UnmarshalJSON

func (ni *NullInt64) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullString

type NullString struct {
	sql.NullString
}

NullString 空字符串

func NewNullString

func NewNullString() NullString

NewNullString ...

func NewString

func NewString(s string) NullString

NewString ...

func (NullString) Convert

func (ns NullString) Convert() string

Convert ...

func (NullString) IsEmpty

func (ns NullString) IsEmpty() bool

IsEmpty ...

func (NullString) IsValid

func (ns NullString) IsValid() bool

IsValid ...

func (NullString) MarshalJSON

func (ns NullString) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullString) Result

func (ns NullString) Result() interface{}

Result ...

func (*NullString) UnmarshalJSON

func (ns *NullString) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullTime

type NullTime struct {
	sql.NullString
}

NullTime 空字符串

func NewNullTime

func NewNullTime() NullTime

NewNullTime ...

func NewTime

func NewTime(s interface{}) NullTime

NewTime ...

func (NullTime) IsEmpty

func (nt NullTime) IsEmpty() bool

IsEmpty ...

func (NullTime) IsValid

func (nt NullTime) IsValid() bool

IsValid ...

func (NullTime) MarshalJSON

func (nt NullTime) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullTime) Result

func (nt NullTime) Result() interface{}

Result ...

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan ...

func (*NullTime) UnmarshalJSON

func (nt *NullTime) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullTimeStamp

type NullTimeStamp struct {
	sql.NullString
}

NullTimeStamp NullYear 空字符串

func NewNullTimeStamp

func NewNullTimeStamp() NullTimeStamp

NewNullTimeStamp ...

func NewTimeStamp

func NewTimeStamp(s interface{}) NullTimeStamp

NewTimeStamp ...

func (NullTimeStamp) IsEmpty

func (nt NullTimeStamp) IsEmpty() bool

IsEmpty ...

func (NullTimeStamp) IsValid

func (nt NullTimeStamp) IsValid() bool

IsValid ...

func (NullTimeStamp) MarshalJSON

func (nt NullTimeStamp) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullTimeStamp) Result

func (nt NullTimeStamp) Result() interface{}

Result ...

func (*NullTimeStamp) Scan

func (nt *NullTimeStamp) Scan(value interface{}) error

Scan ...

func (*NullTimeStamp) UnmarshalJSON

func (nt *NullTimeStamp) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type NullYear

type NullYear struct {
	sql.NullString
}

NullYear 空字符串

func NewNullYear

func NewNullYear() NullYear

NewNullYear ...

func NewYear

func NewYear(s interface{}) NullYear

NewYear ...

func (NullYear) IsEmpty

func (nt NullYear) IsEmpty() bool

IsEmpty ...

func (NullYear) IsValid

func (nt NullYear) IsValid() bool

IsValid ...

func (NullYear) MarshalJSON

func (nt NullYear) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (NullYear) Result

func (nt NullYear) Result() interface{}

Result ...

func (*NullYear) Scan

func (nt *NullYear) Scan(value interface{}) error

Scan ...

func (*NullYear) UnmarshalJSON

func (nt *NullYear) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type Nullable

type Nullable interface {
	IsEmpty() bool
	IsValid() bool
}

Nullable ...

type Opt

type Opt struct {
	MaxLifetime  time.Duration //连接池里面的连接最大存活时长
	MaxIdleTime  time.Duration //连接池里面的连接最大空闲时长
	MaxOpenConns int           //连接池最多同时打开的连接数
	MaxIdleConns int           //连接池里最大空闲连接数。必须要比maxOpenConns小
}

Opt ...

type Query added in v3.1.8

type Query struct {
	DB            *sql.DB
	SQL           SQL
	DriverName    string
	DisableMetric bool // 关闭指标采集
	DisableTrace  bool // 关闭链路追踪
	Prepare       bool
	DBName        string
	Addr          string
	Func          string // 上个函数调用的函数名称
	Path          string // 上个函数调用的函数位置
}

Query 构造查询

func (*Query) Begin added in v3.1.9

func (query *Query) Begin() (*Transaction, error)

Begin 开启一个事务

func (*Query) Exec added in v3.1.8

func (query *Query) Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error)

Exec 复用执行语句

func (*Query) LastSQL added in v3.1.9

func (query *Query) LastSQL(querySQL string, args ...interface{})

LastSQL ...

func (*Query) NewBuilder added in v3.1.9

func (query *Query) NewBuilder(ctx context.Context) *Builder

NewBuilder 生成一个新的查询构造器

func (*Query) Query added in v3.1.9

func (query *Query) Query(ctx context.Context, querySQL string, args ...interface{}) (*sql.Rows, error)

Query 复用查询语句

func (*Query) SQLRaw added in v3.1.9

func (query *Query) SQLRaw() string

SQLRaw ...

type ResourceManager

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

ResourceManager A ResourceManager is a manager that used to manage resources.

func NewResourceManager

func NewResourceManager() *ResourceManager

NewResourceManager returns a ResourceManager.

func (*ResourceManager) Close

func (manager *ResourceManager) Close() error

Close closes the manager. Don't use the ResourceManager after Close() called.

func (*ResourceManager) GetResource

func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (io.Closer, error)

GetResource returns the resource associated with given key.

type Row

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

Row 获取记录

func (*Row) ToArray

func (r *Row) ToArray() (result []string, err error)

ToArray get Array

func (*Row) ToInterface

func (r *Row) ToInterface() (result map[string]interface{}, err error)

ToInterface ...

func (*Row) ToMap

func (r *Row) ToMap() (result map[string]string, err error)

ToMap get Map

func (*Row) ToStruct

func (r *Row) ToStruct(st interface{}) error

ToStruct get Struct

type Rows

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

Rows get data

func (*Rows) ToArray

func (r *Rows) ToArray() (data [][]string, err error)

ToArray get Array

func (*Rows) ToInterface

func (r *Rows) ToInterface() (data []map[string]interface{}, err error)

ToInterface []map[interface{}]interface{}

func (*Rows) ToMap

func (r *Rows) ToMap() (data []map[string]string, err error)

ToMap get Map

func (*Rows) ToStruct

func (r *Rows) ToStruct(st interface{}) error

ToStruct get Struct

type SQL added in v3.1.7

type SQL struct {
	SQL      string
	Args     []interface{}
	CostTime time.Duration
}

SQL sql语句

func (SQL) ToJSON added in v3.1.8

func (sql SQL) ToJSON() string

ToJSON sql语句转出json

func (SQL) ToString added in v3.1.7

func (SQLRaw SQL) ToString() string

ToString sql语句转出string

type SharedCalls

type SharedCalls = SingleFlight

SharedCalls is an alias of SingleFlight. Deprecated: use SingleFlight.

type SingleFlight

type SingleFlight interface {
	Do(key string, fn func() (interface{}, error)) (interface{}, error)
	DoEx(key string, fn func() (interface{}, error)) (interface{}, bool, error)
}

SingleFlight lets the concurrent calls with the same key to share the call result. For example, A called F, before it's done, B called F. Then B would not execute F, and shared the result returned by F which called by A. The calls with the same key are dependent, concurrent calls share the returned values. A ------->calls F with key<------------------->returns val B --------------------->calls F with key------>returns val

func NewSharedCalls

func NewSharedCalls() SingleFlight

NewSharedCalls returns a SingleFlight. Deprecated: use NewSingleFlight.

func NewSingleFlight

func NewSingleFlight() SingleFlight

NewSingleFlight returns a SingleFlight.

type Transaction added in v3.1.9

type Transaction struct {
	Transaction   *sql.Tx
	SQL           SQL
	DriverName    string
	DisableMetric bool // 关闭指标采集
	DisableTrace  bool // 关闭链路追踪
	Prepare       bool
	DBName        string
	Addr          string
	Func          string // 上个函数调用的函数名称
	Path          string // 上个函数调用的函数位置
}

Transaction 事务

func (*Transaction) Commit added in v3.1.9

func (query *Transaction) Commit() error

Commit 事务提交

func (*Transaction) Exec added in v3.1.9

func (query *Transaction) Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error)

Exec 复用执行语句

func (*Transaction) LastSQL added in v3.1.9

func (query *Transaction) LastSQL(querySQL string, args ...interface{})

LastSQL ...

func (*Transaction) NewBuilder added in v3.1.9

func (query *Transaction) NewBuilder(ctx context.Context) *Builder

NewBuilder 生成一个新的查询构造器

func (*Transaction) Query added in v3.1.9

func (query *Transaction) Query(ctx context.Context, querySQL string, args ...interface{}) (*sql.Rows, error)

Query 复用查询语句

func (*Transaction) Rollback added in v3.1.9

func (query *Transaction) Rollback() error

Rollback 事务回滚

func (*Transaction) SQLRaw added in v3.1.9

func (query *Transaction) SQLRaw() string

SQLRaw ...

Jump to

Keyboard shortcuts

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