Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) ExecContext(ctx context.Context, query string, args ...any) (result sql.Result, err error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) BeginTx(ctx context.Context, opts *sql.TxOptions) (Transaction, error) Conn(ctx context.Context) (*sql.Conn, error) Close() error }
func NewPrepared ¶
func NewPrepared[T Transaction](db Wrapped[T]) Interface
NewPrepared creates a new Interface that wraps the given database and uses a prepare cache to reduce the number of prepare calls. The cache is only used when calling ExecContext and QueryContext methods on the main instance or in a transaction.
type Transaction ¶
type Transaction interface { QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) ExecContext(ctx context.Context, query string, args ...any) (result sql.Result, err error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) StmtContext(ctx context.Context, stmt *sql.Stmt) *sql.Stmt Commit() error Rollback() error }
type Wrapped ¶
type Wrapped[T Transaction] interface { QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) ExecContext(ctx context.Context, query string, args ...any) (result sql.Result, err error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) BeginTx(ctx context.Context, opts *sql.TxOptions) (T, error) Conn(ctx context.Context) (*sql.Conn, error) Close() error }
Click to show internal directories.
Click to hide internal directories.