Documentation
¶
Overview ¶
Package sqln maintains a map of queries to named statements and uses named statements for all operations.
Index ¶
- type DB
- type Database
- func (d *Database) Close() error
- func (d *Database) Exec(ctx context.Context, query string, params interface{}) (sql.Result, error)
- func (d *Database) Get(ctx context.Context, query string, dest, params interface{}) error
- func (d *Database) Select(ctx context.Context, query string, dest, params interface{}) error
- func (d *Database) Stmt(query string) (*sqlx.NamedStmt, error)
- func (d *Database) Transact(ctx context.Context, opts sql.TxOptions, f func(DB) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { Exec(ctx context.Context, query string, params interface{}) (sql.Result, error) Get(ctx context.Context, query string, dest, params interface{}) error Select(ctx context.Context, query string, dest, params interface{}) error // Stmt creates a named statement if one does not exist. It is not safe // to Close the returned statement. Stmt(query string) (*sqlx.NamedStmt, error) // TODO: Implement nested transactions. Transact(ctx context.Context, opts sql.TxOptions, f func(DB) error) error }
DB is an interface to allow for the Transact method to return a non-concrete type which is useful when wrapping this implementation.
type Database ¶
Database wraps a sqlx.DB and manages NamedStmt's.
func (*Database) Transact ¶
Transact will run the function that is passed in, rolling back all SQL statements if an error is returned. NOTE: A non-nil TxOptions struct is accepted to encourage thoughtful selection of transaction isolation levels. NOTE: Nested transactions are not currently supported and will return an error.
Click to show internal directories.
Click to hide internal directories.