bundb

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 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

DBService satisfies the DB interface

func (*DBService) DB

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

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

type UpsertQuery

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

func NewUpsert(idb bun.IDB) *UpsertQuery

func (*UpsertQuery) Column

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

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

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

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

Model sets the model or models to upsert.

func (*UpsertQuery) Scan

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