bundb

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: AGPL-3.0 Imports: 51 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 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