Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotInTransaction is returned when using Commit // outside of a transaction. ErrNotInTransaction = errors.New("not in transaction") // ErrIncompatibleOption is returned when using an option incompatible // with the selected driver. ErrIncompatibleOption = errors.New("incompatible option") )
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
sqlx.Execer
sqlx.ExecerContext
sqlx.Queryer
sqlx.QueryerContext
sqlx.Preparer
sqlx.PreparerContext
BindNamed(query string, arg interface{}) (string, []interface{}, error)
DriverName() string
Get(dest interface{}, query string, args ...interface{}) error
GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
MustExec(query string, args ...interface{}) sql.Result
MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
NamedExec(query string, arg interface{}) (sql.Result, error)
NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
PrepareNamed(query string) (*sqlx.NamedStmt, error)
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
Preparex(query string) (*sqlx.Stmt, error)
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
QueryRow(string, ...interface{}) *sql.Row
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
Rebind(query string) string
Select(dest interface{}, query string, args ...interface{}) error
SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}
A Driver can query the database. It can either be a *sqlx.DB or a *sqlx.Tx and therefore is limited to the methods they have in common.
type Node ¶
type Node interface {
Driver
// Close the underlying sqlx connection.
Close() error
// Begin a new transaction.
Beginx() (Node, error)
// Begin a new transaction using the provided context and options.
// Note that the provided parameters are only used when opening a new transaction,
// not on nested ones.
BeginTxx(ctx context.Context, opts *sql.TxOptions) (Node, error)
// Rollback the associated transaction.
Rollback() error
// Commit the assiociated transaction.
Commit() error
// Tx returns the underlying transaction.
Tx() *sqlx.Tx
}
A Node is a database driver that can manage nested transactions.
Click to show internal directories.
Click to hide internal directories.