bundb

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBunDBService

func NewBunDBService(ctx context.Context, state *state.State) (db.DB, error)

NewBunDBService returns a bunDB derived from the provided config, which implements the go-fed DB interface. Under the hood, it uses https://github.com/uptrace/bun to create and maintain a database connection.

Types

type DB added in v0.11.1

type DB struct {
	// contains filtered or unexported fields
}

DB wraps a bun database instance to provide common per-dialect SQL error conversions to common types, and retries on returned busy (SQLite only).

func WrapDB added in v0.11.0

func WrapDB(db *bun.DB) *DB

WrapDB wraps a bun database instance in our database type.

func (*DB) AddQueryHook added in v0.11.1

func (db *DB) AddQueryHook(hook bun.QueryHook)

AddQueryHook is a direct call-through to bun.DB.AddQueryHook().

func (*DB) BeginTx added in v0.11.1

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (tx Tx, err error)

BeginTx wraps bun.DB.BeginTx() with retry-busy timeout and our own error processing.

func (*DB) Close added in v0.11.1

func (db *DB) Close() error

Close is a direct call-through to bun.DB.Close().

func (*DB) Dialect added in v0.11.1

func (db *DB) Dialect() schema.Dialect

Dialect is a direct call-through to bun.DB.Dialect().

func (*DB) ExecContext added in v0.11.1

func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (result sql.Result, err error)

ExecContext wraps bun.DB.ExecContext() with retry-busy timeout and our own error processing.

func (*DB) Exists added in v0.11.1

func (db *DB) Exists(ctx context.Context, query *bun.SelectQuery) (bool, error)

Exists checks the results of a SelectQuery for the existence of the data in question, masking ErrNoEntries errors.

func (*DB) NewAddColumn added in v0.11.1

func (db *DB) NewAddColumn() *bun.AddColumnQuery

func (*DB) NewCreateIndex added in v0.11.1

func (db *DB) NewCreateIndex() *bun.CreateIndexQuery

func (*DB) NewCreateTable added in v0.11.1

func (db *DB) NewCreateTable() *bun.CreateTableQuery

func (*DB) NewDelete added in v0.11.1

func (db *DB) NewDelete() *bun.DeleteQuery

func (*DB) NewDropColumn added in v0.11.1

func (db *DB) NewDropColumn() *bun.DropColumnQuery

func (*DB) NewDropIndex added in v0.11.1

func (db *DB) NewDropIndex() *bun.DropIndexQuery

func (*DB) NewDropTable added in v0.11.1

func (db *DB) NewDropTable() *bun.DropTableQuery

func (*DB) NewInsert added in v0.11.1

func (db *DB) NewInsert() *bun.InsertQuery

func (*DB) NewMerge added in v0.11.1

func (db *DB) NewMerge() *bun.MergeQuery

func (*DB) NewRaw added in v0.11.1

func (db *DB) NewRaw(query string, args ...interface{}) *bun.RawQuery

func (*DB) NewSelect added in v0.11.1

func (db *DB) NewSelect() *bun.SelectQuery

func (*DB) NewTruncateTable added in v0.11.1

func (db *DB) NewTruncateTable() *bun.TruncateTableQuery

func (*DB) NewUpdate added in v0.11.1

func (db *DB) NewUpdate() *bun.UpdateQuery

func (*DB) NewValues added in v0.11.1

func (db *DB) NewValues(model interface{}) *bun.ValuesQuery

func (*DB) NotExists added in v0.11.1

func (db *DB) NotExists(ctx context.Context, query *bun.SelectQuery) (bool, error)

NotExists checks the results of a SelectQuery for the non-existence of the data in question, masking ErrNoEntries errors.

func (*DB) PingContext added in v0.11.1

func (db *DB) PingContext(ctx context.Context) error

PingContext is a direct call-through to bun.DB.PingContext().

func (*DB) QueryContext added in v0.11.1

func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (rows *sql.Rows, err error)

QueryContext wraps bun.DB.ExecContext() with retry-busy timeout and our own error processing.

func (*DB) QueryRowContext added in v0.11.1

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) (row *sql.Row)

QueryRowContext wraps bun.DB.ExecContext() with retry-busy timeout and our own error processing.

func (*DB) RegisterModel added in v0.11.1

func (db *DB) RegisterModel(models ...any)

RegisterModels is a direct call-through to bun.DB.RegisterModels().

func (*DB) RunInTx added in v0.11.1

func (db *DB) RunInTx(ctx context.Context, fn func(Tx) error) error

RunInTx is functionally the same as bun.DB.RunInTx() but with retry-busy timeouts.

type DBService added in v0.5.0

DBService satisfies the DB interface

func (*DBService) DB added in v0.11.0

func (dbService *DBService) DB() *DB

GetDB returns the underlying database connection pool. Should only be used in testing + exceptional circumstance.

type Tx added in v0.12.0

type Tx struct {
	// contains filtered or unexported fields
}

Tx wraps a bun transaction instance to provide common per-dialect SQL error conversions to common types, and retries on busy commit/rollback (SQLite only).

func (Tx) Commit added in v0.12.0

func (tx Tx) Commit() (err error)

Commit wraps bun.Tx.Commit() with retry-busy timeout and our own error processing.

func (Tx) Dialect added in v0.12.0

func (tx Tx) Dialect() schema.Dialect

Dialect is a direct call-through to bun.DB.Dialect().

func (Tx) ExecContext added in v0.12.0

func (tx Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

ExecContext wraps bun.Tx.ExecContext() with our own error processing, WITHOUT retry-busy timeouts (as will be mid-transaction).

func (Tx) NewAddColumn added in v0.12.0

func (tx Tx) NewAddColumn() *bun.AddColumnQuery

func (Tx) NewCreateIndex added in v0.12.0

func (tx Tx) NewCreateIndex() *bun.CreateIndexQuery

func (Tx) NewCreateTable added in v0.12.0

func (tx Tx) NewCreateTable() *bun.CreateTableQuery

func (Tx) NewDelete added in v0.12.0

func (tx Tx) NewDelete() *bun.DeleteQuery

func (Tx) NewDropColumn added in v0.12.0

func (tx Tx) NewDropColumn() *bun.DropColumnQuery

func (Tx) NewDropIndex added in v0.12.0

func (tx Tx) NewDropIndex() *bun.DropIndexQuery

func (Tx) NewDropTable added in v0.12.0

func (tx Tx) NewDropTable() *bun.DropTableQuery

func (Tx) NewInsert added in v0.12.0

func (tx Tx) NewInsert() *bun.InsertQuery

func (Tx) NewMerge added in v0.12.0

func (tx Tx) NewMerge() *bun.MergeQuery

func (Tx) NewRaw added in v0.12.0

func (tx Tx) NewRaw(query string, args ...interface{}) *bun.RawQuery

func (Tx) NewSelect added in v0.12.0

func (tx Tx) NewSelect() *bun.SelectQuery

func (Tx) NewTruncateTable added in v0.12.0

func (tx Tx) NewTruncateTable() *bun.TruncateTableQuery

func (Tx) NewUpdate added in v0.12.0

func (tx Tx) NewUpdate() *bun.UpdateQuery

func (Tx) NewValues added in v0.12.0

func (tx Tx) NewValues(model interface{}) *bun.ValuesQuery

func (Tx) QueryContext added in v0.12.0

func (tx Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

QueryContext wraps bun.Tx.QueryContext() with our own error processing, WITHOUT retry-busy timeouts (as will be mid-transaction).

func (Tx) QueryRowContext added in v0.12.0

func (tx Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRowContext wraps bun.Tx.QueryRowContext() with our own error processing, WITHOUT retry-busy timeouts (as will be mid-transaction).

func (Tx) Rollback added in v0.12.0

func (tx Tx) Rollback() (err error)

Rollback wraps bun.Tx.Rollback() with retry-busy timeout and our own error processing.

Directories

Path Synopsis
20211113114307_init
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
20220214175650_media_cleanup
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
20220315160814_admin_account_actions
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL