Documentation ¶
Index ¶
- func WithConnMaxIdleTime(d time.Duration) func(*DB) error
- func WithConnMaxLifetime(d time.Duration) func(*DB) error
- func WithMaxIdelConns(conns int) func(*DB) error
- func WithMaxOpenConns(conns int) func(*DB) error
- type DB
- func (db *DB) Close()
- func (db *DB) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (db *DB) Ping() error
- func (db *DB) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (db *DB) WithTransaction(ctx context.Context, fn func(context.Context) error) error
- type Scanable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithConnMaxIdleTime ¶
WithConnMaxIdleTime is a database option that sets the maximum idle time of a connection
func WithConnMaxLifetime ¶
WithConnMaxLifetime is a database option that sets the maximum lifttime of a connection
func WithMaxIdelConns ¶
WithMaxIdelConns is a database option that sets the maximum number of idle connections
func WithMaxOpenConns ¶
WithMaxOpenConns is a database option that sets the maximum number of open connections
Types ¶
type DB ¶
type DB struct { DB *sql.DB Connector driver.Connector // MaxOpenConns is the maximum number of open connections to the database. MaxOpenConns int // MaxIdelConns is the maximum number of connections in the idle connection pool. MaxIdelConns int // ConnMaxLifetime is the maximum lifetime of a connection. ConnMaxLifetime time.Duration // ConnMaxIdelTime is the maximum lifetime of an idle connection. ConnMaxIdelTime time.Duration }
DB is the management interface for the standard database handle
Click to show internal directories.
Click to hide internal directories.