database

package
v0.0.103 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BunAdapter

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

BunAdapter adapts Bun to work with our Database interface This demonstrates how the abstraction works with different ORMs

func NewBunAdapter

func NewBunAdapter(db *bun.DB) *BunAdapter

NewBunAdapter creates a new Bun adapter

func (*BunAdapter) BeginTx

func (b *BunAdapter) BeginTx(ctx context.Context) (common.Database, error)

func (*BunAdapter) CommitTx

func (b *BunAdapter) CommitTx(ctx context.Context) error

func (*BunAdapter) DisableQueryDebug added in v0.0.93

func (b *BunAdapter) DisableQueryDebug()

DisableQueryDebug removes all query hooks

func (*BunAdapter) EnableDetailedScanDebug added in v0.0.100

func (b *BunAdapter) EnableDetailedScanDebug()

EnableDetailedScanDebug enables verbose logging of scan operations WARNING: This generates a LOT of log output. Use only for debugging specific issues.

func (*BunAdapter) EnableQueryDebug added in v0.0.93

func (b *BunAdapter) EnableQueryDebug()

EnableQueryDebug enables query debugging which logs all SQL queries including preloads This is useful for debugging preload queries that may be failing

func (*BunAdapter) Exec

func (b *BunAdapter) Exec(ctx context.Context, query string, args ...interface{}) (res common.Result, err error)

func (*BunAdapter) NewDelete

func (b *BunAdapter) NewDelete() common.DeleteQuery

func (*BunAdapter) NewInsert

func (b *BunAdapter) NewInsert() common.InsertQuery

func (*BunAdapter) NewSelect

func (b *BunAdapter) NewSelect() common.SelectQuery

func (*BunAdapter) NewUpdate

func (b *BunAdapter) NewUpdate() common.UpdateQuery

func (*BunAdapter) Query

func (b *BunAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

func (*BunAdapter) RollbackTx

func (b *BunAdapter) RollbackTx(ctx context.Context) error

func (*BunAdapter) RunInTransaction

func (b *BunAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) (err error)

type BunDeleteQuery

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

BunDeleteQuery implements DeleteQuery for Bun

func (*BunDeleteQuery) Exec

func (b *BunDeleteQuery) Exec(ctx context.Context) (res common.Result, err error)

func (*BunDeleteQuery) Model

func (b *BunDeleteQuery) Model(model interface{}) common.DeleteQuery

func (*BunDeleteQuery) Table

func (b *BunDeleteQuery) Table(table string) common.DeleteQuery

func (*BunDeleteQuery) Where

func (b *BunDeleteQuery) Where(query string, args ...interface{}) common.DeleteQuery

type BunInsertQuery

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

BunInsertQuery implements InsertQuery for Bun

func (*BunInsertQuery) Exec

func (b *BunInsertQuery) Exec(ctx context.Context) (res common.Result, err error)

func (*BunInsertQuery) Model

func (b *BunInsertQuery) Model(model interface{}) common.InsertQuery

func (*BunInsertQuery) OnConflict

func (b *BunInsertQuery) OnConflict(action string) common.InsertQuery

func (*BunInsertQuery) Returning

func (b *BunInsertQuery) Returning(columns ...string) common.InsertQuery

func (*BunInsertQuery) Table

func (b *BunInsertQuery) Table(table string) common.InsertQuery

func (*BunInsertQuery) Value

func (b *BunInsertQuery) Value(column string, value interface{}) common.InsertQuery

type BunResult

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

BunResult implements Result for Bun

func (*BunResult) LastInsertId

func (b *BunResult) LastInsertId() (int64, error)

func (*BunResult) RowsAffected

func (b *BunResult) RowsAffected() int64

type BunSelectQuery

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

BunSelectQuery implements SelectQuery for Bun

func (*BunSelectQuery) Column

func (b *BunSelectQuery) Column(columns ...string) common.SelectQuery

func (*BunSelectQuery) ColumnExpr added in v0.0.22

func (b *BunSelectQuery) ColumnExpr(query string, args ...interface{}) common.SelectQuery

func (*BunSelectQuery) Count

func (b *BunSelectQuery) Count(ctx context.Context) (count int, err error)

func (*BunSelectQuery) Exists

func (b *BunSelectQuery) Exists(ctx context.Context) (exists bool, err error)

func (*BunSelectQuery) Group

func (b *BunSelectQuery) Group(group string) common.SelectQuery

func (*BunSelectQuery) Having

func (b *BunSelectQuery) Having(having string, args ...interface{}) common.SelectQuery

func (*BunSelectQuery) Join

func (b *BunSelectQuery) Join(query string, args ...interface{}) common.SelectQuery

func (*BunSelectQuery) JoinRelation added in v0.0.95

func (b *BunSelectQuery) JoinRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery

func (*BunSelectQuery) LeftJoin

func (b *BunSelectQuery) LeftJoin(query string, args ...interface{}) common.SelectQuery

func (*BunSelectQuery) Limit

func (b *BunSelectQuery) Limit(n int) common.SelectQuery

func (*BunSelectQuery) Model

func (b *BunSelectQuery) Model(model interface{}) common.SelectQuery

func (*BunSelectQuery) Offset

func (b *BunSelectQuery) Offset(n int) common.SelectQuery

func (*BunSelectQuery) Order

func (b *BunSelectQuery) Order(order string) common.SelectQuery

func (*BunSelectQuery) Preload

func (b *BunSelectQuery) Preload(relation string, conditions ...interface{}) common.SelectQuery

func (*BunSelectQuery) PreloadRelation added in v0.0.23

func (b *BunSelectQuery) PreloadRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery

func (*BunSelectQuery) Scan

func (b *BunSelectQuery) Scan(ctx context.Context, dest interface{}) (err error)

func (*BunSelectQuery) ScanModel added in v0.0.21

func (b *BunSelectQuery) ScanModel(ctx context.Context) (err error)

func (*BunSelectQuery) Table

func (b *BunSelectQuery) Table(table string) common.SelectQuery

func (*BunSelectQuery) Where

func (b *BunSelectQuery) Where(query string, args ...interface{}) common.SelectQuery

func (*BunSelectQuery) WhereOr

func (b *BunSelectQuery) WhereOr(query string, args ...interface{}) common.SelectQuery

type BunTxAdapter

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

BunTxAdapter wraps a Bun transaction to implement the Database interface

func (*BunTxAdapter) BeginTx

func (b *BunTxAdapter) BeginTx(ctx context.Context) (common.Database, error)

func (*BunTxAdapter) CommitTx

func (b *BunTxAdapter) CommitTx(ctx context.Context) error

func (*BunTxAdapter) Exec

func (b *BunTxAdapter) Exec(ctx context.Context, query string, args ...interface{}) (common.Result, error)

func (*BunTxAdapter) NewDelete

func (b *BunTxAdapter) NewDelete() common.DeleteQuery

func (*BunTxAdapter) NewInsert

func (b *BunTxAdapter) NewInsert() common.InsertQuery

func (*BunTxAdapter) NewSelect

func (b *BunTxAdapter) NewSelect() common.SelectQuery

func (*BunTxAdapter) NewUpdate

func (b *BunTxAdapter) NewUpdate() common.UpdateQuery

func (*BunTxAdapter) Query

func (b *BunTxAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*BunTxAdapter) RollbackTx

func (b *BunTxAdapter) RollbackTx(ctx context.Context) error

func (*BunTxAdapter) RunInTransaction

func (b *BunTxAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) error

type BunUpdateQuery

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

BunUpdateQuery implements UpdateQuery for Bun

func (*BunUpdateQuery) Exec

func (b *BunUpdateQuery) Exec(ctx context.Context) (res common.Result, err error)

func (*BunUpdateQuery) Model

func (b *BunUpdateQuery) Model(model interface{}) common.UpdateQuery

func (*BunUpdateQuery) Returning

func (b *BunUpdateQuery) Returning(columns ...string) common.UpdateQuery

func (*BunUpdateQuery) Set

func (b *BunUpdateQuery) Set(column string, value interface{}) common.UpdateQuery

func (*BunUpdateQuery) SetMap

func (b *BunUpdateQuery) SetMap(values map[string]interface{}) common.UpdateQuery

func (*BunUpdateQuery) Table

func (b *BunUpdateQuery) Table(table string) common.UpdateQuery

func (*BunUpdateQuery) Where

func (b *BunUpdateQuery) Where(query string, args ...interface{}) common.UpdateQuery

type GormAdapter

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

GormAdapter adapts GORM to work with our Database interface

func NewGormAdapter

func NewGormAdapter(db *gorm.DB) *GormAdapter

NewGormAdapter creates a new GORM adapter

func (*GormAdapter) BeginTx

func (g *GormAdapter) BeginTx(ctx context.Context) (common.Database, error)

func (*GormAdapter) CommitTx

func (g *GormAdapter) CommitTx(ctx context.Context) error

func (*GormAdapter) DisableQueryDebug added in v0.0.93

func (g *GormAdapter) DisableQueryDebug() *GormAdapter

DisableQueryDebug disables query debugging

func (*GormAdapter) EnableQueryDebug added in v0.0.93

func (g *GormAdapter) EnableQueryDebug() *GormAdapter

EnableQueryDebug enables query debugging which logs all SQL queries including preloads This is useful for debugging preload queries that may be failing

func (*GormAdapter) Exec

func (g *GormAdapter) Exec(ctx context.Context, query string, args ...interface{}) (res common.Result, err error)

func (*GormAdapter) NewDelete

func (g *GormAdapter) NewDelete() common.DeleteQuery

func (*GormAdapter) NewInsert

func (g *GormAdapter) NewInsert() common.InsertQuery

func (*GormAdapter) NewSelect

func (g *GormAdapter) NewSelect() common.SelectQuery

func (*GormAdapter) NewUpdate

func (g *GormAdapter) NewUpdate() common.UpdateQuery

func (*GormAdapter) Query

func (g *GormAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

func (*GormAdapter) RollbackTx

func (g *GormAdapter) RollbackTx(ctx context.Context) error

func (*GormAdapter) RunInTransaction

func (g *GormAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) (err error)

type GormDeleteQuery

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

GormDeleteQuery implements DeleteQuery for GORM

func (*GormDeleteQuery) Exec

func (g *GormDeleteQuery) Exec(ctx context.Context) (res common.Result, err error)

func (*GormDeleteQuery) Model

func (g *GormDeleteQuery) Model(model interface{}) common.DeleteQuery

func (*GormDeleteQuery) Table

func (g *GormDeleteQuery) Table(table string) common.DeleteQuery

func (*GormDeleteQuery) Where

func (g *GormDeleteQuery) Where(query string, args ...interface{}) common.DeleteQuery

type GormInsertQuery

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

GormInsertQuery implements InsertQuery for GORM

func (*GormInsertQuery) Exec

func (g *GormInsertQuery) Exec(ctx context.Context) (res common.Result, err error)

func (*GormInsertQuery) Model

func (g *GormInsertQuery) Model(model interface{}) common.InsertQuery

func (*GormInsertQuery) OnConflict

func (g *GormInsertQuery) OnConflict(action string) common.InsertQuery

func (*GormInsertQuery) Returning

func (g *GormInsertQuery) Returning(columns ...string) common.InsertQuery

func (*GormInsertQuery) Table

func (g *GormInsertQuery) Table(table string) common.InsertQuery

func (*GormInsertQuery) Value

func (g *GormInsertQuery) Value(column string, value interface{}) common.InsertQuery

type GormResult

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

GormResult implements Result for GORM

func (*GormResult) LastInsertId

func (g *GormResult) LastInsertId() (int64, error)

func (*GormResult) RowsAffected

func (g *GormResult) RowsAffected() int64

type GormSelectQuery

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

GormSelectQuery implements SelectQuery for GORM

func (*GormSelectQuery) Column

func (g *GormSelectQuery) Column(columns ...string) common.SelectQuery

func (*GormSelectQuery) ColumnExpr added in v0.0.22

func (g *GormSelectQuery) ColumnExpr(query string, args ...interface{}) common.SelectQuery

func (*GormSelectQuery) Count

func (g *GormSelectQuery) Count(ctx context.Context) (count int, err error)

func (*GormSelectQuery) Exists

func (g *GormSelectQuery) Exists(ctx context.Context) (exists bool, err error)

func (*GormSelectQuery) Group

func (g *GormSelectQuery) Group(group string) common.SelectQuery

func (*GormSelectQuery) Having

func (g *GormSelectQuery) Having(having string, args ...interface{}) common.SelectQuery

func (*GormSelectQuery) Join

func (g *GormSelectQuery) Join(query string, args ...interface{}) common.SelectQuery

func (*GormSelectQuery) JoinRelation added in v0.0.95

func (g *GormSelectQuery) JoinRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery

func (*GormSelectQuery) LeftJoin

func (g *GormSelectQuery) LeftJoin(query string, args ...interface{}) common.SelectQuery

func (*GormSelectQuery) Limit

func (g *GormSelectQuery) Limit(n int) common.SelectQuery

func (*GormSelectQuery) Model

func (g *GormSelectQuery) Model(model interface{}) common.SelectQuery

func (*GormSelectQuery) Offset

func (g *GormSelectQuery) Offset(n int) common.SelectQuery

func (*GormSelectQuery) Order

func (g *GormSelectQuery) Order(order string) common.SelectQuery

func (*GormSelectQuery) Preload

func (g *GormSelectQuery) Preload(relation string, conditions ...interface{}) common.SelectQuery

func (*GormSelectQuery) PreloadRelation added in v0.0.23

func (g *GormSelectQuery) PreloadRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery

func (*GormSelectQuery) Scan

func (g *GormSelectQuery) Scan(ctx context.Context, dest interface{}) (err error)

func (*GormSelectQuery) ScanModel added in v0.0.21

func (g *GormSelectQuery) ScanModel(ctx context.Context) (err error)

func (*GormSelectQuery) Table

func (g *GormSelectQuery) Table(table string) common.SelectQuery

func (*GormSelectQuery) Where

func (g *GormSelectQuery) Where(query string, args ...interface{}) common.SelectQuery

func (*GormSelectQuery) WhereOr

func (g *GormSelectQuery) WhereOr(query string, args ...interface{}) common.SelectQuery

type GormUpdateQuery

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

GormUpdateQuery implements UpdateQuery for GORM

func (*GormUpdateQuery) Exec

func (g *GormUpdateQuery) Exec(ctx context.Context) (res common.Result, err error)

func (*GormUpdateQuery) Model

func (g *GormUpdateQuery) Model(model interface{}) common.UpdateQuery

func (*GormUpdateQuery) Returning

func (g *GormUpdateQuery) Returning(columns ...string) common.UpdateQuery

func (*GormUpdateQuery) Set

func (g *GormUpdateQuery) Set(column string, value interface{}) common.UpdateQuery

func (*GormUpdateQuery) SetMap

func (g *GormUpdateQuery) SetMap(values map[string]interface{}) common.UpdateQuery

func (*GormUpdateQuery) Table

func (g *GormUpdateQuery) Table(table string) common.UpdateQuery

func (*GormUpdateQuery) Where

func (g *GormUpdateQuery) Where(query string, args ...interface{}) common.UpdateQuery

type QueryDebugHook added in v0.0.93

type QueryDebugHook struct{}

QueryDebugHook is a Bun query hook that logs all SQL queries including preloads

func (*QueryDebugHook) AfterQuery added in v0.0.93

func (h *QueryDebugHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)

func (*QueryDebugHook) BeforeQuery added in v0.0.93

func (h *QueryDebugHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context

Jump to

Keyboard shortcuts

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