bundb

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 52 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 DBService added in v0.5.0

DBService satisfies the DB interface

func (*DBService) DB added in v0.11.0

func (dbService *DBService) DB() *bun.DB

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

type PostgreSQLConn added in v0.14.0

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

func (*PostgreSQLConn) Begin added in v0.14.0

func (c *PostgreSQLConn) Begin() (driver.Tx, error)

func (*PostgreSQLConn) BeginTx added in v0.14.0

func (c *PostgreSQLConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

func (*PostgreSQLConn) Close added in v0.14.0

func (c *PostgreSQLConn) Close() error

func (*PostgreSQLConn) Exec added in v0.14.0

func (c *PostgreSQLConn) Exec(query string, args []driver.Value) (driver.Result, error)

func (*PostgreSQLConn) ExecContext added in v0.14.0

func (c *PostgreSQLConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)

func (*PostgreSQLConn) Prepare added in v0.14.0

func (c *PostgreSQLConn) Prepare(query string) (driver.Stmt, error)

func (*PostgreSQLConn) PrepareContext added in v0.14.0

func (c *PostgreSQLConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

func (*PostgreSQLConn) Query added in v0.14.0

func (c *PostgreSQLConn) Query(query string, args []driver.Value) (driver.Rows, error)

func (*PostgreSQLConn) QueryContext added in v0.14.0

func (c *PostgreSQLConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

type PostgreSQLDriver added in v0.14.0

type PostgreSQLDriver struct{}

PostgreSQLDriver is our own wrapper around the pgx/stdlib.Driver{} type in order to wrap further SQL driver types with our own err processing.

func (*PostgreSQLDriver) Open added in v0.14.0

func (d *PostgreSQLDriver) Open(name string) (driver.Conn, error)

type PostgreSQLStmt added in v0.14.0

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

func (*PostgreSQLStmt) Exec added in v0.14.0

func (stmt *PostgreSQLStmt) Exec(args []driver.Value) (driver.Result, error)

func (*PostgreSQLStmt) ExecContext added in v0.14.0

func (stmt *PostgreSQLStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)

func (*PostgreSQLStmt) Query added in v0.14.0

func (stmt *PostgreSQLStmt) Query(args []driver.Value) (driver.Rows, error)

func (*PostgreSQLStmt) QueryContext added in v0.14.0

func (stmt *PostgreSQLStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)

type PostgreSQLTx added in v0.14.0

type PostgreSQLTx struct{ driver.Tx }

func (*PostgreSQLTx) Commit added in v0.14.0

func (tx *PostgreSQLTx) Commit() error

func (*PostgreSQLTx) Rollback added in v0.14.0

func (tx *PostgreSQLTx) Rollback() error

type SQLiteConn added in v0.14.0

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

func (*SQLiteConn) Begin added in v0.14.0

func (c *SQLiteConn) Begin() (driver.Tx, error)

func (*SQLiteConn) BeginTx added in v0.14.0

func (c *SQLiteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.Tx, err error)

func (*SQLiteConn) Close added in v0.14.0

func (c *SQLiteConn) Close() error

func (*SQLiteConn) Exec added in v0.14.0

func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, error)

func (*SQLiteConn) ExecContext added in v0.14.0

func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (result driver.Result, err error)

func (*SQLiteConn) Prepare added in v0.14.0

func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error)

func (*SQLiteConn) PrepareContext added in v0.14.0

func (c *SQLiteConn) PrepareContext(ctx context.Context, query string) (st driver.Stmt, err error)

func (*SQLiteConn) Query added in v0.14.0

func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, error)

func (*SQLiteConn) QueryContext added in v0.14.0

func (c *SQLiteConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (rows driver.Rows, err error)

type SQLiteDriver added in v0.14.0

type SQLiteDriver struct{}

SQLiteDriver is our own wrapper around the sqlite.Driver{} type in order to wrap further SQL driver types with our own functionality, e.g. hooks, retries and err processing.

func (*SQLiteDriver) Open added in v0.14.0

func (d *SQLiteDriver) Open(name string) (driver.Conn, error)

type SQLiteStmt added in v0.14.0

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

func (*SQLiteStmt) Exec added in v0.14.0

func (stmt *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error)

func (*SQLiteStmt) ExecContext added in v0.14.0

func (stmt *SQLiteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (res driver.Result, err error)

func (*SQLiteStmt) Query added in v0.14.0

func (stmt *SQLiteStmt) Query(args []driver.Value) (driver.Rows, error)

func (*SQLiteStmt) QueryContext added in v0.14.0

func (stmt *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (rows driver.Rows, err error)

type SQLiteTx added in v0.14.0

type SQLiteTx struct {
	context.Context
	driver.Tx
}

func (*SQLiteTx) Commit added in v0.14.0

func (tx *SQLiteTx) Commit() (err error)

func (*SQLiteTx) Rollback added in v0.14.0

func (tx *SQLiteTx) Rollback() (err error)

type UpsertQuery added in v0.15.0

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

UpsertQuery is a wrapper around an insert query that can update if an insert fails. Doesn't implement the full set of Bun query methods, but we can add more if we need them. See https://bun.uptrace.dev/guide/query-insert.html#upsert

func NewUpsert added in v0.15.0

func NewUpsert(idb bun.IDB) *UpsertQuery

func (*UpsertQuery) Column added in v0.15.0

func (u *UpsertQuery) Column(columns ...string) *UpsertQuery

Column sets the columns to update if an insert does't happen. If empty, all columns not being used for constraints will be updated. Cannot overlap with Constraint.

func (*UpsertQuery) Constraint added in v0.15.0

func (u *UpsertQuery) Constraint(constraints ...string) *UpsertQuery

Constraint sets the columns or indexes that are used to check for conflicts. This is required.

func (*UpsertQuery) Exec added in v0.15.0

func (u *UpsertQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

Exec builds a Bun insert query from the upsert query, and executes it.

func (*UpsertQuery) Model added in v0.15.0

func (u *UpsertQuery) Model(model interface{}) *UpsertQuery

Model sets the model or models to upsert.

func (*UpsertQuery) Scan added in v0.15.0

func (u *UpsertQuery) Scan(ctx context.Context, dest ...interface{}) error

Scan builds a Bun insert query from the upsert query, and scans it.

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