bundb

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: AGPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBunDBService

func NewBunDBService(ctx context.Context) (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 DBConn

type DBConn struct {
	*bun.DB // DB is the underlying bun.DB connection
	// contains filtered or unexported fields
}

DBConn wrapps a bun.DB conn to provide SQL-type specific additional functionality

func WrapDBConn

func WrapDBConn(dbConn *bun.DB) *DBConn

WrapDBConn wraps a bun DB connection to provide our own error processing dependent on DB dialect.

func (*DBConn) Exists

func (conn *DBConn) Exists(ctx context.Context, query *bun.SelectQuery) (bool, db.Error)

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

func (*DBConn) NotExists

func (conn *DBConn) NotExists(ctx context.Context, query *bun.SelectQuery) (bool, db.Error)

NotExists is the functional opposite of conn.Exists()

func (*DBConn) ProcessError

func (conn *DBConn) ProcessError(err error) db.Error

ProcessError processes an error to replace any known values with our own db.Error types, making it easier to catch specific situations (e.g. no rows, already exists, etc)

func (*DBConn) RunInTx

func (conn *DBConn) RunInTx(ctx context.Context, fn func(bun.Tx) error) db.Error

RunInTx wraps execution of the supplied transaction function.

type DBService added in v0.5.0

type DBService struct {
	db.Account
	db.Admin
	db.Basic
	db.Domain
	db.Emoji
	db.Instance
	db.Media
	db.Mention
	db.Notification
	db.Relationship
	db.Session
	db.Status
	db.Timeline
	// contains filtered or unexported fields
}

DBService satisfies the DB interface

func (*DBService) GetConn added in v0.5.0

func (dbService *DBService) GetConn() *DBConn

GetConn returns the underlying bun connection. Should only be used in testing + exceptional circumstance.

func (*DBService) TagStringsToTags added in v0.5.0

func (dbService *DBService) TagStringsToTags(ctx context.Context, tags []string, originAccountID string) ([]*gtsmodel.Tag, error)

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