Documentation
¶
Index ¶
- func ExampleCompleteWorkflow() error
- func ExampleJoinRelation() error
- func ExamplePgSQLAdapter() error
- func ExamplePreload() error
- func ExamplePreloadRelation() error
- func ExampleScanModel() error
- func ExampleWithModel() error
- type Author
- type BunAdapter
- func (b *BunAdapter) BeginTx(ctx context.Context) (common.Database, error)
- func (b *BunAdapter) CommitTx(ctx context.Context) error
- func (b *BunAdapter) DisableQueryDebug()
- func (b *BunAdapter) EnableDetailedScanDebug()
- func (b *BunAdapter) EnableQueryDebug()
- func (b *BunAdapter) Exec(ctx context.Context, query string, args ...interface{}) (res common.Result, err error)
- func (b *BunAdapter) GetUnderlyingDB() interface{}
- func (b *BunAdapter) NewDelete() common.DeleteQuery
- func (b *BunAdapter) NewInsert() common.InsertQuery
- func (b *BunAdapter) NewSelect() common.SelectQuery
- func (b *BunAdapter) NewUpdate() common.UpdateQuery
- func (b *BunAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)
- func (b *BunAdapter) RollbackTx(ctx context.Context) error
- func (b *BunAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) (err error)
- type BunDeleteQuery
- type BunInsertQuery
- func (b *BunInsertQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (b *BunInsertQuery) Model(model interface{}) common.InsertQuery
- func (b *BunInsertQuery) OnConflict(action string) common.InsertQuery
- func (b *BunInsertQuery) Returning(columns ...string) common.InsertQuery
- func (b *BunInsertQuery) Table(table string) common.InsertQuery
- func (b *BunInsertQuery) Value(column string, value interface{}) common.InsertQuery
- type BunResult
- type BunSelectQuery
- func (b *BunSelectQuery) Column(columns ...string) common.SelectQuery
- func (b *BunSelectQuery) ColumnExpr(query string, args ...interface{}) common.SelectQuery
- func (b *BunSelectQuery) Count(ctx context.Context) (count int, err error)
- func (b *BunSelectQuery) Exists(ctx context.Context) (exists bool, err error)
- func (b *BunSelectQuery) Group(group string) common.SelectQuery
- func (b *BunSelectQuery) Having(having string, args ...interface{}) common.SelectQuery
- func (b *BunSelectQuery) Join(query string, args ...interface{}) common.SelectQuery
- func (b *BunSelectQuery) JoinRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
- func (b *BunSelectQuery) LeftJoin(query string, args ...interface{}) common.SelectQuery
- func (b *BunSelectQuery) Limit(n int) common.SelectQuery
- func (b *BunSelectQuery) Model(model interface{}) common.SelectQuery
- func (b *BunSelectQuery) Offset(n int) common.SelectQuery
- func (b *BunSelectQuery) Order(order string) common.SelectQuery
- func (b *BunSelectQuery) OrderExpr(order string, args ...interface{}) common.SelectQuery
- func (b *BunSelectQuery) Preload(relation string, conditions ...interface{}) common.SelectQuery
- func (b *BunSelectQuery) PreloadRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
- func (b *BunSelectQuery) Scan(ctx context.Context, dest interface{}) (err error)
- func (b *BunSelectQuery) ScanModel(ctx context.Context) (err error)
- func (b *BunSelectQuery) Table(table string) common.SelectQuery
- func (b *BunSelectQuery) Where(query string, args ...interface{}) common.SelectQuery
- func (b *BunSelectQuery) WhereOr(query string, args ...interface{}) common.SelectQuery
- type BunTxAdapter
- func (b *BunTxAdapter) BeginTx(ctx context.Context) (common.Database, error)
- func (b *BunTxAdapter) CommitTx(ctx context.Context) error
- func (b *BunTxAdapter) Exec(ctx context.Context, query string, args ...interface{}) (common.Result, error)
- func (b *BunTxAdapter) GetUnderlyingDB() interface{}
- func (b *BunTxAdapter) NewDelete() common.DeleteQuery
- func (b *BunTxAdapter) NewInsert() common.InsertQuery
- func (b *BunTxAdapter) NewSelect() common.SelectQuery
- func (b *BunTxAdapter) NewUpdate() common.UpdateQuery
- func (b *BunTxAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (b *BunTxAdapter) RollbackTx(ctx context.Context) error
- func (b *BunTxAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) error
- type BunUpdateQuery
- func (b *BunUpdateQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (b *BunUpdateQuery) Model(model interface{}) common.UpdateQuery
- func (b *BunUpdateQuery) Returning(columns ...string) common.UpdateQuery
- func (b *BunUpdateQuery) Set(column string, value interface{}) common.UpdateQuery
- func (b *BunUpdateQuery) SetMap(values map[string]interface{}) common.UpdateQuery
- func (b *BunUpdateQuery) Table(table string) common.UpdateQuery
- func (b *BunUpdateQuery) Where(query string, args ...interface{}) common.UpdateQuery
- type Comment
- type GormAdapter
- func (g *GormAdapter) BeginTx(ctx context.Context) (common.Database, error)
- func (g *GormAdapter) CommitTx(ctx context.Context) error
- func (g *GormAdapter) DisableQueryDebug() *GormAdapter
- func (g *GormAdapter) EnableQueryDebug() *GormAdapter
- func (g *GormAdapter) Exec(ctx context.Context, query string, args ...interface{}) (res common.Result, err error)
- func (g *GormAdapter) GetUnderlyingDB() interface{}
- func (g *GormAdapter) NewDelete() common.DeleteQuery
- func (g *GormAdapter) NewInsert() common.InsertQuery
- func (g *GormAdapter) NewSelect() common.SelectQuery
- func (g *GormAdapter) NewUpdate() common.UpdateQuery
- func (g *GormAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)
- func (g *GormAdapter) RollbackTx(ctx context.Context) error
- func (g *GormAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) (err error)
- type GormDeleteQuery
- func (g *GormDeleteQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (g *GormDeleteQuery) Model(model interface{}) common.DeleteQuery
- func (g *GormDeleteQuery) Table(table string) common.DeleteQuery
- func (g *GormDeleteQuery) Where(query string, args ...interface{}) common.DeleteQuery
- type GormInsertQuery
- func (g *GormInsertQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (g *GormInsertQuery) Model(model interface{}) common.InsertQuery
- func (g *GormInsertQuery) OnConflict(action string) common.InsertQuery
- func (g *GormInsertQuery) Returning(columns ...string) common.InsertQuery
- func (g *GormInsertQuery) Table(table string) common.InsertQuery
- func (g *GormInsertQuery) Value(column string, value interface{}) common.InsertQuery
- type GormResult
- type GormSelectQuery
- func (g *GormSelectQuery) Column(columns ...string) common.SelectQuery
- func (g *GormSelectQuery) ColumnExpr(query string, args ...interface{}) common.SelectQuery
- func (g *GormSelectQuery) Count(ctx context.Context) (count int, err error)
- func (g *GormSelectQuery) Exists(ctx context.Context) (exists bool, err error)
- func (g *GormSelectQuery) Group(group string) common.SelectQuery
- func (g *GormSelectQuery) Having(having string, args ...interface{}) common.SelectQuery
- func (g *GormSelectQuery) Join(query string, args ...interface{}) common.SelectQuery
- func (g *GormSelectQuery) JoinRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
- func (g *GormSelectQuery) LeftJoin(query string, args ...interface{}) common.SelectQuery
- func (g *GormSelectQuery) Limit(n int) common.SelectQuery
- func (g *GormSelectQuery) Model(model interface{}) common.SelectQuery
- func (g *GormSelectQuery) Offset(n int) common.SelectQuery
- func (g *GormSelectQuery) Order(order string) common.SelectQuery
- func (g *GormSelectQuery) OrderExpr(order string, args ...interface{}) common.SelectQuery
- func (g *GormSelectQuery) Preload(relation string, conditions ...interface{}) common.SelectQuery
- func (g *GormSelectQuery) PreloadRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
- func (g *GormSelectQuery) Scan(ctx context.Context, dest interface{}) (err error)
- func (g *GormSelectQuery) ScanModel(ctx context.Context) (err error)
- func (g *GormSelectQuery) Table(table string) common.SelectQuery
- func (g *GormSelectQuery) Where(query string, args ...interface{}) common.SelectQuery
- func (g *GormSelectQuery) WhereOr(query string, args ...interface{}) common.SelectQuery
- type GormUpdateQuery
- func (g *GormUpdateQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (g *GormUpdateQuery) Model(model interface{}) common.UpdateQuery
- func (g *GormUpdateQuery) Returning(columns ...string) common.UpdateQuery
- func (g *GormUpdateQuery) Set(column string, value interface{}) common.UpdateQuery
- func (g *GormUpdateQuery) SetMap(values map[string]interface{}) common.UpdateQuery
- func (g *GormUpdateQuery) Table(table string) common.UpdateQuery
- func (g *GormUpdateQuery) Where(query string, args ...interface{}) common.UpdateQuery
- type PgSQLAdapter
- func (p *PgSQLAdapter) BeginTx(ctx context.Context) (common.Database, error)
- func (p *PgSQLAdapter) CommitTx(ctx context.Context) error
- func (p *PgSQLAdapter) EnableQueryDebug()
- func (p *PgSQLAdapter) Exec(ctx context.Context, query string, args ...interface{}) (res common.Result, err error)
- func (p *PgSQLAdapter) GetUnderlyingDB() interface{}
- func (p *PgSQLAdapter) NewDelete() common.DeleteQuery
- func (p *PgSQLAdapter) NewInsert() common.InsertQuery
- func (p *PgSQLAdapter) NewSelect() common.SelectQuery
- func (p *PgSQLAdapter) NewUpdate() common.UpdateQuery
- func (p *PgSQLAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)
- func (p *PgSQLAdapter) RollbackTx(ctx context.Context) error
- func (p *PgSQLAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) (err error)
- type PgSQLDeleteQuery
- func (p *PgSQLDeleteQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (p *PgSQLDeleteQuery) Model(model interface{}) common.DeleteQuery
- func (p *PgSQLDeleteQuery) Table(table string) common.DeleteQuery
- func (p *PgSQLDeleteQuery) Where(query string, args ...interface{}) common.DeleteQuery
- type PgSQLInsertQuery
- func (p *PgSQLInsertQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (p *PgSQLInsertQuery) Model(model interface{}) common.InsertQuery
- func (p *PgSQLInsertQuery) OnConflict(action string) common.InsertQuery
- func (p *PgSQLInsertQuery) Returning(columns ...string) common.InsertQuery
- func (p *PgSQLInsertQuery) Table(table string) common.InsertQuery
- func (p *PgSQLInsertQuery) Value(column string, value interface{}) common.InsertQuery
- type PgSQLResult
- type PgSQLSelectQuery
- func (p *PgSQLSelectQuery) Column(columns ...string) common.SelectQuery
- func (p *PgSQLSelectQuery) ColumnExpr(query string, args ...interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) Count(ctx context.Context) (count int, err error)
- func (p *PgSQLSelectQuery) Exists(ctx context.Context) (exists bool, err error)
- func (p *PgSQLSelectQuery) Group(group string) common.SelectQuery
- func (p *PgSQLSelectQuery) Having(having string, args ...interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) Join(query string, args ...interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) JoinRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
- func (p *PgSQLSelectQuery) LeftJoin(query string, args ...interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) Limit(n int) common.SelectQuery
- func (p *PgSQLSelectQuery) Model(model interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) Offset(n int) common.SelectQuery
- func (p *PgSQLSelectQuery) Order(order string) common.SelectQuery
- func (p *PgSQLSelectQuery) OrderExpr(order string, args ...interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) Preload(relation string, conditions ...interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) PreloadRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
- func (p *PgSQLSelectQuery) Scan(ctx context.Context, dest interface{}) (err error)
- func (p *PgSQLSelectQuery) ScanModel(ctx context.Context) error
- func (p *PgSQLSelectQuery) Table(table string) common.SelectQuery
- func (p *PgSQLSelectQuery) Where(query string, args ...interface{}) common.SelectQuery
- func (p *PgSQLSelectQuery) WhereOr(query string, args ...interface{}) common.SelectQuery
- type PgSQLTxAdapter
- func (p *PgSQLTxAdapter) BeginTx(ctx context.Context) (common.Database, error)
- func (p *PgSQLTxAdapter) CommitTx(ctx context.Context) error
- func (p *PgSQLTxAdapter) Exec(ctx context.Context, query string, args ...interface{}) (common.Result, error)
- func (p *PgSQLTxAdapter) GetUnderlyingDB() interface{}
- func (p *PgSQLTxAdapter) NewDelete() common.DeleteQuery
- func (p *PgSQLTxAdapter) NewInsert() common.InsertQuery
- func (p *PgSQLTxAdapter) NewSelect() common.SelectQuery
- func (p *PgSQLTxAdapter) NewUpdate() common.UpdateQuery
- func (p *PgSQLTxAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (p *PgSQLTxAdapter) RollbackTx(ctx context.Context) error
- func (p *PgSQLTxAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) error
- type PgSQLUpdateQuery
- func (p *PgSQLUpdateQuery) Exec(ctx context.Context) (res common.Result, err error)
- func (p *PgSQLUpdateQuery) Model(model interface{}) common.UpdateQuery
- func (p *PgSQLUpdateQuery) Returning(columns ...string) common.UpdateQuery
- func (p *PgSQLUpdateQuery) Set(column string, value interface{}) common.UpdateQuery
- func (p *PgSQLUpdateQuery) SetMap(values map[string]interface{}) common.UpdateQuery
- func (p *PgSQLUpdateQuery) Table(table string) common.UpdateQuery
- func (p *PgSQLUpdateQuery) Where(query string, args ...interface{}) common.UpdateQuery
- type Post
- type QueryDebugHook
- type TestHelper
- func (h *TestHelper) AssertUserCount(expected int)
- func (h *TestHelper) AssertUserExists(email string)
- func (h *TestHelper) BeginTestTransaction() (*PgSQLTxAdapter, func())
- func (h *TestHelper) CleanupTables()
- func (h *TestHelper) GetUserByEmail(email string) map[string]interface{}
- func (h *TestHelper) InsertComment(postID int, content string) int
- func (h *TestHelper) InsertPost(userID int, title, content string, published bool) int
- func (h *TestHelper) InsertUser(name, email string, age int) int
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExampleCompleteWorkflow ¶ added in v0.0.104
func ExampleCompleteWorkflow() error
ExampleCompleteWorkflow demonstrates a complete workflow with preloading
func ExampleJoinRelation ¶ added in v0.0.104
func ExampleJoinRelation() error
ExampleJoinRelation demonstrates explicit JOIN loading
func ExamplePgSQLAdapter ¶ added in v0.0.104
func ExamplePgSQLAdapter() error
Example demonstrates how to use the PgSQL adapter
func ExamplePreload ¶ added in v0.0.104
func ExamplePreload() error
ExamplePreload demonstrates the Preload functionality
func ExamplePreloadRelation ¶ added in v0.0.104
func ExamplePreloadRelation() error
ExamplePreloadRelation demonstrates smart PreloadRelation with auto-detection
func ExampleScanModel ¶ added in v0.0.104
func ExampleScanModel() error
ExampleScanModel demonstrates ScanModel with struct destinations
func ExampleWithModel ¶ added in v0.0.104
func ExampleWithModel() error
ExampleWithModel demonstrates using models with the PgSQL adapter
Types ¶
type Author ¶ added in v0.0.104
type Author struct {
ID int `db:"id"`
Name string `db:"name"`
Email string `db:"email"`
Posts []*Post `bun:"rel:has-many,join:id=author_id"`
}
Author model - has many Posts
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) 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) GetUnderlyingDB ¶ added in v0.0.107
func (b *BunAdapter) GetUnderlyingDB() interface{}
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 ¶
type BunDeleteQuery ¶
type BunDeleteQuery struct {
// contains filtered or unexported fields
}
BunDeleteQuery implements DeleteQuery for Bun
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) 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 (*BunResult) RowsAffected ¶
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) OrderExpr ¶ added in v0.0.109
func (b *BunSelectQuery) OrderExpr(order string, args ...interface{}) 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) GetUnderlyingDB ¶ added in v0.0.107
func (b *BunTxAdapter) GetUnderlyingDB() interface{}
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 ¶
type BunUpdateQuery ¶
type BunUpdateQuery struct {
// contains filtered or unexported fields
}
BunUpdateQuery implements UpdateQuery for Bun
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 Comment ¶ added in v0.0.104
type Comment struct {
ID int `db:"id"`
Content string `db:"content"`
PostID int `db:"post_id"`
Post *Post `bun:"rel:belongs-to,join:post_id=id"`
}
Comment model - belongs to Post
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) 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) GetUnderlyingDB ¶ added in v0.0.107
func (g *GormAdapter) GetUnderlyingDB() interface{}
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 ¶
type GormDeleteQuery ¶
type GormDeleteQuery struct {
// contains filtered or unexported fields
}
GormDeleteQuery implements DeleteQuery for GORM
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) 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) OrderExpr ¶ added in v0.0.109
func (g *GormSelectQuery) OrderExpr(order string, args ...interface{}) 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) 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 PgSQLAdapter ¶ added in v0.0.104
type PgSQLAdapter struct {
// contains filtered or unexported fields
}
PgSQLAdapter adapts standard database/sql to work with our Database interface This provides a lightweight PostgreSQL adapter without ORM overhead
func NewPgSQLAdapter ¶ added in v0.0.104
func NewPgSQLAdapter(db *sql.DB) *PgSQLAdapter
NewPgSQLAdapter creates a new PostgreSQL adapter
func (*PgSQLAdapter) CommitTx ¶ added in v0.0.104
func (p *PgSQLAdapter) CommitTx(ctx context.Context) error
func (*PgSQLAdapter) EnableQueryDebug ¶ added in v0.0.104
func (p *PgSQLAdapter) EnableQueryDebug()
EnableQueryDebug enables query debugging for development
func (*PgSQLAdapter) GetUnderlyingDB ¶ added in v0.0.107
func (p *PgSQLAdapter) GetUnderlyingDB() interface{}
func (*PgSQLAdapter) NewDelete ¶ added in v0.0.104
func (p *PgSQLAdapter) NewDelete() common.DeleteQuery
func (*PgSQLAdapter) NewInsert ¶ added in v0.0.104
func (p *PgSQLAdapter) NewInsert() common.InsertQuery
func (*PgSQLAdapter) NewSelect ¶ added in v0.0.104
func (p *PgSQLAdapter) NewSelect() common.SelectQuery
func (*PgSQLAdapter) NewUpdate ¶ added in v0.0.104
func (p *PgSQLAdapter) NewUpdate() common.UpdateQuery
func (*PgSQLAdapter) Query ¶ added in v0.0.104
func (p *PgSQLAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)
func (*PgSQLAdapter) RollbackTx ¶ added in v0.0.104
func (p *PgSQLAdapter) RollbackTx(ctx context.Context) error
func (*PgSQLAdapter) RunInTransaction ¶ added in v0.0.104
type PgSQLDeleteQuery ¶ added in v0.0.104
type PgSQLDeleteQuery struct {
// contains filtered or unexported fields
}
PgSQLDeleteQuery implements DeleteQuery for PostgreSQL
func (*PgSQLDeleteQuery) Model ¶ added in v0.0.104
func (p *PgSQLDeleteQuery) Model(model interface{}) common.DeleteQuery
func (*PgSQLDeleteQuery) Table ¶ added in v0.0.104
func (p *PgSQLDeleteQuery) Table(table string) common.DeleteQuery
func (*PgSQLDeleteQuery) Where ¶ added in v0.0.104
func (p *PgSQLDeleteQuery) Where(query string, args ...interface{}) common.DeleteQuery
type PgSQLInsertQuery ¶ added in v0.0.104
type PgSQLInsertQuery struct {
// contains filtered or unexported fields
}
PgSQLInsertQuery implements InsertQuery for PostgreSQL
func (*PgSQLInsertQuery) Model ¶ added in v0.0.104
func (p *PgSQLInsertQuery) Model(model interface{}) common.InsertQuery
func (*PgSQLInsertQuery) OnConflict ¶ added in v0.0.104
func (p *PgSQLInsertQuery) OnConflict(action string) common.InsertQuery
func (*PgSQLInsertQuery) Returning ¶ added in v0.0.104
func (p *PgSQLInsertQuery) Returning(columns ...string) common.InsertQuery
func (*PgSQLInsertQuery) Table ¶ added in v0.0.104
func (p *PgSQLInsertQuery) Table(table string) common.InsertQuery
func (*PgSQLInsertQuery) Value ¶ added in v0.0.104
func (p *PgSQLInsertQuery) Value(column string, value interface{}) common.InsertQuery
type PgSQLResult ¶ added in v0.0.104
type PgSQLResult struct {
// contains filtered or unexported fields
}
PgSQLResult implements Result for PostgreSQL
func (*PgSQLResult) LastInsertId ¶ added in v0.0.104
func (p *PgSQLResult) LastInsertId() (int64, error)
func (*PgSQLResult) RowsAffected ¶ added in v0.0.104
func (p *PgSQLResult) RowsAffected() int64
type PgSQLSelectQuery ¶ added in v0.0.104
type PgSQLSelectQuery struct {
// contains filtered or unexported fields
}
PgSQLSelectQuery implements SelectQuery for PostgreSQL
func (*PgSQLSelectQuery) Column ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Column(columns ...string) common.SelectQuery
func (*PgSQLSelectQuery) ColumnExpr ¶ added in v0.0.104
func (p *PgSQLSelectQuery) ColumnExpr(query string, args ...interface{}) common.SelectQuery
func (*PgSQLSelectQuery) Count ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Count(ctx context.Context) (count int, err error)
func (*PgSQLSelectQuery) Exists ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Exists(ctx context.Context) (exists bool, err error)
func (*PgSQLSelectQuery) Group ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Group(group string) common.SelectQuery
func (*PgSQLSelectQuery) Having ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Having(having string, args ...interface{}) common.SelectQuery
func (*PgSQLSelectQuery) Join ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Join(query string, args ...interface{}) common.SelectQuery
func (*PgSQLSelectQuery) JoinRelation ¶ added in v0.0.104
func (p *PgSQLSelectQuery) JoinRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
func (*PgSQLSelectQuery) LeftJoin ¶ added in v0.0.104
func (p *PgSQLSelectQuery) LeftJoin(query string, args ...interface{}) common.SelectQuery
func (*PgSQLSelectQuery) Limit ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Limit(n int) common.SelectQuery
func (*PgSQLSelectQuery) Model ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Model(model interface{}) common.SelectQuery
func (*PgSQLSelectQuery) Offset ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Offset(n int) common.SelectQuery
func (*PgSQLSelectQuery) Order ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Order(order string) common.SelectQuery
func (*PgSQLSelectQuery) OrderExpr ¶ added in v0.0.109
func (p *PgSQLSelectQuery) OrderExpr(order string, args ...interface{}) common.SelectQuery
func (*PgSQLSelectQuery) Preload ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Preload(relation string, conditions ...interface{}) common.SelectQuery
func (*PgSQLSelectQuery) PreloadRelation ¶ added in v0.0.104
func (p *PgSQLSelectQuery) PreloadRelation(relation string, apply ...func(common.SelectQuery) common.SelectQuery) common.SelectQuery
func (*PgSQLSelectQuery) Scan ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Scan(ctx context.Context, dest interface{}) (err error)
func (*PgSQLSelectQuery) ScanModel ¶ added in v0.0.104
func (p *PgSQLSelectQuery) ScanModel(ctx context.Context) error
func (*PgSQLSelectQuery) Table ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Table(table string) common.SelectQuery
func (*PgSQLSelectQuery) Where ¶ added in v0.0.104
func (p *PgSQLSelectQuery) Where(query string, args ...interface{}) common.SelectQuery
func (*PgSQLSelectQuery) WhereOr ¶ added in v0.0.104
func (p *PgSQLSelectQuery) WhereOr(query string, args ...interface{}) common.SelectQuery
type PgSQLTxAdapter ¶ added in v0.0.104
type PgSQLTxAdapter struct {
// contains filtered or unexported fields
}
PgSQLTxAdapter wraps a PostgreSQL transaction
func (*PgSQLTxAdapter) CommitTx ¶ added in v0.0.104
func (p *PgSQLTxAdapter) CommitTx(ctx context.Context) error
func (*PgSQLTxAdapter) GetUnderlyingDB ¶ added in v0.0.107
func (p *PgSQLTxAdapter) GetUnderlyingDB() interface{}
func (*PgSQLTxAdapter) NewDelete ¶ added in v0.0.104
func (p *PgSQLTxAdapter) NewDelete() common.DeleteQuery
func (*PgSQLTxAdapter) NewInsert ¶ added in v0.0.104
func (p *PgSQLTxAdapter) NewInsert() common.InsertQuery
func (*PgSQLTxAdapter) NewSelect ¶ added in v0.0.104
func (p *PgSQLTxAdapter) NewSelect() common.SelectQuery
func (*PgSQLTxAdapter) NewUpdate ¶ added in v0.0.104
func (p *PgSQLTxAdapter) NewUpdate() common.UpdateQuery
func (*PgSQLTxAdapter) Query ¶ added in v0.0.104
func (p *PgSQLTxAdapter) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*PgSQLTxAdapter) RollbackTx ¶ added in v0.0.104
func (p *PgSQLTxAdapter) RollbackTx(ctx context.Context) error
func (*PgSQLTxAdapter) RunInTransaction ¶ added in v0.0.104
type PgSQLUpdateQuery ¶ added in v0.0.104
type PgSQLUpdateQuery struct {
// contains filtered or unexported fields
}
PgSQLUpdateQuery implements UpdateQuery for PostgreSQL
func (*PgSQLUpdateQuery) Model ¶ added in v0.0.104
func (p *PgSQLUpdateQuery) Model(model interface{}) common.UpdateQuery
func (*PgSQLUpdateQuery) Returning ¶ added in v0.0.104
func (p *PgSQLUpdateQuery) Returning(columns ...string) common.UpdateQuery
func (*PgSQLUpdateQuery) Set ¶ added in v0.0.104
func (p *PgSQLUpdateQuery) Set(column string, value interface{}) common.UpdateQuery
func (*PgSQLUpdateQuery) SetMap ¶ added in v0.0.104
func (p *PgSQLUpdateQuery) SetMap(values map[string]interface{}) common.UpdateQuery
func (*PgSQLUpdateQuery) Table ¶ added in v0.0.104
func (p *PgSQLUpdateQuery) Table(table string) common.UpdateQuery
func (*PgSQLUpdateQuery) Where ¶ added in v0.0.104
func (p *PgSQLUpdateQuery) Where(query string, args ...interface{}) common.UpdateQuery
type Post ¶ added in v0.0.104
type Post struct {
ID int `db:"id"`
Title string `db:"title"`
Content string `db:"content"`
AuthorID int `db:"author_id"`
Author *Author `bun:"rel:belongs-to,join:author_id=id"`
Comments []*Comment `bun:"rel:has-many,join:id=post_id"`
}
Post model - belongs to Author, has many Comments
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
type TestHelper ¶ added in v0.0.104
type TestHelper struct {
DB *sql.DB
Adapter *PgSQLAdapter
// contains filtered or unexported fields
}
TestHelper provides utilities for database testing
func NewTestHelper ¶ added in v0.0.104
func NewTestHelper(t *testing.T, db *sql.DB) *TestHelper
NewTestHelper creates a new test helper
func (*TestHelper) AssertUserCount ¶ added in v0.0.104
func (h *TestHelper) AssertUserCount(expected int)
AssertUserCount asserts the number of users
func (*TestHelper) AssertUserExists ¶ added in v0.0.104
func (h *TestHelper) AssertUserExists(email string)
AssertUserExists checks if a user exists by email
func (*TestHelper) BeginTestTransaction ¶ added in v0.0.104
func (h *TestHelper) BeginTestTransaction() (*PgSQLTxAdapter, func())
BeginTestTransaction starts a transaction for testing
func (*TestHelper) CleanupTables ¶ added in v0.0.104
func (h *TestHelper) CleanupTables()
CleanupTables truncates all test tables
func (*TestHelper) GetUserByEmail ¶ added in v0.0.104
func (h *TestHelper) GetUserByEmail(email string) map[string]interface{}
GetUserByEmail retrieves a user by email
func (*TestHelper) InsertComment ¶ added in v0.0.104
func (h *TestHelper) InsertComment(postID int, content string) int
InsertComment inserts a test comment and returns the ID
func (*TestHelper) InsertPost ¶ added in v0.0.104
func (h *TestHelper) InsertPost(userID int, title, content string, published bool) int
InsertPost inserts a test post and returns the ID
func (*TestHelper) InsertUser ¶ added in v0.0.104
func (h *TestHelper) InsertUser(name, email string, age int) int
InsertUser inserts a test user and returns the ID