Documentation ¶
Index ¶
- Constants
- func Query[T any](db *DB, query string, pointers func(*T) []interface{}, args ...any) ([]T, error)
- func QueryContext[T any](ctx context.Context, db *DB, query string, pointers func(*T) []interface{}, ...) ([]T, error)
- type DB
- func (db *DB) DoTx(f func(db dbx.DBxer[*sql.DB, *sql.Tx, *sql.TxOptions]) error, ...) error
- func (db *DB) DoTxContext(ctx context.Context, ...) error
- func (db *DB) Exec(query string, args ...any) (sql.Result, error)
- func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (db *DB) Prepare(query string) (*sql.Stmt, error)
- func (db *DB) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
- func (db *DB) Query(query string, args ...any) (*sql.Rows, error)
- func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (db *DB) QueryRow(query string, args ...any) dbx.Row
- func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) dbx.Row
- func (db *DB) Tx() (*sql.Tx, error)
- func (db *DB) WithDefaultNode(criteria cluster.NodeStateCriteria) *DB
- func (db *DB) WithReadFromNode(criteria cluster.NodeStateCriteria) *DB
- func (db *DB) WithWriteToNode(criteria cluster.NodeStateCriteria) *DB
- type DBOpener
- type ErrRow
- type Option
Constants ¶
View Source
const DefaultPingTimeout = 15 * time.Second
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
func NewDB ¶
func NewDB(driverName string, dsns []string, checker cluster.NodeChecker[*sql.DB], options ...Option) (*DB, error)
NewDB returns an instance of *DB.
func (*DB) DoTx ¶
func (db *DB) DoTx(f func(db dbx.DBxer[*sql.DB, *sql.Tx, *sql.TxOptions]) error, opts *sql.TxOptions) error
DoTx executes passed function in transaction.
func (*DB) DoTxContext ¶
func (db *DB) DoTxContext( ctx context.Context, f func(ctx context.Context, db dbx.DBxer[*sql.DB, *sql.Tx, *sql.TxOptions]) error, opts *sql.TxOptions) error
DoTxContext executes passed function in transaction.
func (*DB) ExecContext ¶
ExecContext executes query with context.
func (*DB) PrepareContext ¶
PrepareContext prepares query with context.
func (*DB) QueryContext ¶
QueryContext queries underlying cluster with context.
func (*DB) QueryRowContext ¶
QueryRowContext queries row from underlying cluster with context.
func (*DB) WithDefaultNode ¶
func (db *DB) WithDefaultNode(criteria cluster.NodeStateCriteria) *DB
func (*DB) WithReadFromNode ¶
func (db *DB) WithReadFromNode(criteria cluster.NodeStateCriteria) *DB
func (*DB) WithWriteToNode ¶
func (db *DB) WithWriteToNode(criteria cluster.NodeStateCriteria) *DB
Click to show internal directories.
Click to hide internal directories.