Documentation
¶
Index ¶
- Constants
- Variables
- func GetLastMigrationAvailable(from uint) (uint, error)
- func IsSerializationError(err error) bool
- func IsUniqueViolation(err error) bool
- func MigrateDown(params params.Database) error
- func MigrateTo(p params.Database, version uint) error
- func MigrateUp(p params.Database) error
- func MigrateVersion(params params.Database) (uint, bool, error)
- func Prefix(prefix string) string
- type Database
- type DatabaseMigrator
- type Migrator
- type QueryOptions
- type Rows
- type SqlxDatabase
- func (d *SqlxDatabase) Close() error
- func (d *SqlxDatabase) Exec(query string, args ...interface{}) (count int64, err error)
- func (d *SqlxDatabase) Get(dest interface{}, query string, args ...interface{}) error
- func (d *SqlxDatabase) Metadata() (map[string]string, error)
- func (d *SqlxDatabase) Queryx(query string, args ...interface{}) (rows *Rows, err error)
- func (d *SqlxDatabase) Stats() sql.DBStats
- func (d *SqlxDatabase) Transact(fn TxFunc, opts ...TxOpt) (interface{}, error)
- func (d *SqlxDatabase) WithContext(ctx context.Context) Database
- type Tx
- type TxFunc
- type TxOpt
- type TxOptions
Constants ¶
View Source
const ( DefaultMaxOpenConnections = 25 DefaultMaxIdleConnections = 25 DefaultConnectionMaxLifetime = 5 * time.Minute DatabaseDriver = "pgx" )
View Source
const ( SerializationRetryMaxAttempts = 10 SerializationRetryStartInterval = time.Millisecond * 2 )
Variables ¶
Functions ¶
func IsSerializationError ¶
func IsUniqueViolation ¶
func MigrateDown ¶
Types ¶
type Database ¶
type Database interface {
io.Closer
Get(dest interface{}, query string, args ...interface{}) error
Queryx(query string, args ...interface{}) (*Rows, error)
Exec(query string, args ...interface{}) (rowsAffected int64, err error)
Transact(fn TxFunc, opts ...TxOpt) (interface{}, error)
Metadata() (map[string]string, error)
Stats() sql.DBStats
WithContext(ctx context.Context) Database
}
func BuildDatabaseConnection ¶ added in v0.9.0
BuildDatabaseConnection returns a database connection based on a pool for the configuration in c.
type DatabaseMigrator ¶
type DatabaseMigrator struct {
// contains filtered or unexported fields
}
func NewDatabaseMigrator ¶
func NewDatabaseMigrator(params params.Database) *DatabaseMigrator
type QueryOptions ¶ added in v0.9.0
type QueryOptions struct {
// contains filtered or unexported fields
}
type SqlxDatabase ¶
type SqlxDatabase struct {
// contains filtered or unexported fields
}
func NewSqlxDatabase ¶
func NewSqlxDatabase(db *sqlx.DB) *SqlxDatabase
func (*SqlxDatabase) Close ¶
func (d *SqlxDatabase) Close() error
func (*SqlxDatabase) Exec ¶ added in v0.9.0
func (d *SqlxDatabase) Exec(query string, args ...interface{}) (count int64, err error)
func (*SqlxDatabase) Get ¶ added in v0.9.0
func (d *SqlxDatabase) Get(dest interface{}, query string, args ...interface{}) error
func (*SqlxDatabase) Queryx ¶
func (d *SqlxDatabase) Queryx(query string, args ...interface{}) (rows *Rows, err error)
func (*SqlxDatabase) Stats ¶
func (d *SqlxDatabase) Stats() sql.DBStats
func (*SqlxDatabase) Transact ¶
func (d *SqlxDatabase) Transact(fn TxFunc, opts ...TxOpt) (interface{}, error)
func (*SqlxDatabase) WithContext ¶ added in v0.9.0
func (d *SqlxDatabase) WithContext(ctx context.Context) Database
type TxOpt ¶
type TxOpt func(*TxOptions)
func WithContext ¶
func WithIsolationLevel ¶
func WithIsolationLevel(level sql.IsolationLevel) TxOpt
func WithLogger ¶
type TxOptions ¶
type TxOptions struct {
// contains filtered or unexported fields
}
func DefaultTxOptions ¶
func DefaultTxOptions() *TxOptions
Source Files
¶
Click to show internal directories.
Click to hide internal directories.