Documentation
¶
Index ¶
- func ConvertArgsToNamedValues(args ...interface{}) []driver.NamedValue
- func ConvertSliceToString(args ...interface{}) (string, error)
- func ConvertToString(arg interface{}) (string, error)
- func GetQuestionMarks(num int) string
- type Command
- type Pool
- type PoolConn
- type Result
- type Statement
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertArgsToNamedValues ¶ added in v0.3.0
func ConvertArgsToNamedValues(args ...interface{}) []driver.NamedValue
ConvertArgsToNamedValues converts args to named values
func ConvertSliceToString ¶ added in v0.3.11
ConvertSliceToString converts args to string, it's usually used to generate "in clause" of a select statement
func ConvertToString ¶ added in v0.3.11
ConvertToString converts an interface type argument to string, it's usually used to generate "in clause" of a select statement
func GetQuestionMarks ¶ added in v0.3.17
GetQuestionMarks returns question marks with given num
Types ¶
type Command ¶ added in v0.3.21
type Command struct {
Statement string `middleware:"statement" json:"statement"`
Args []interface{} `middleware:"args" json:"args"`
}
func NewCommand ¶ added in v0.3.21
NewCommand returns a new *Command
func (*Command) GetMaskedStatement ¶ added in v0.3.21
type Pool ¶
type Pool interface {
// Close releases each connection in the pool
Close() error
// IsClosed returns if pool had been closed
IsClosed() bool
// Get gets a connection from the pool
Get() (PoolConn, error)
// Transaction returns a connection that could run multiple statements in the same transaction
Transaction() (Transaction, error)
// Supply creates given number of connections and add them to the pool
Supply(num int) error
// Release releases given number of connections, each connection will disconnect with the middleware
Release(num int) error
}
type PoolConn ¶
type PoolConn interface {
// Close returns connection back to the pool
Close() error
// Disconnect disconnects from the middleware, normally when using connection pool
Disconnect() error
// IsValid validates if connection is valid
IsValid() bool
// Prepare prepares a statement and returns a Statement
Prepare(command string) (Statement, error)
// PrepareContext prepares a statement with context and returns a Statement
PrepareContext(ctx context.Context, command string) (Statement, error)
// ExecuteInBatch executes given commands and placeholders on the middleware
ExecuteInBatch(commands []*Command, isTransaction bool) ([]Result, error)
// Execute executes given command and placeholders on the middleware
Execute(command string, args ...interface{}) (Result, error)
// ExecuteContext executes given command and placeholders with context on the middleware
ExecuteContext(ctx context.Context, command string, args ...interface{}) (Result, error)
}
type Statement ¶ added in v0.3.0
type Statement interface {
// Close closes the statement
Close() error
// Execute executes given command and placeholders on the middleware
Execute(args ...interface{}) (Result, error)
// ExecuteContext executes given command and placeholders with context on the middleware
ExecuteContext(ctx context.Context, args ...interface{}) (Result, error)
// Commit commits the transaction
Commit() error
// Rollback rollbacks the transaction
Rollback() error
}
Click to show internal directories.
Click to hide internal directories.