Documentation
¶
Index ¶
- func ByID[T any, ID string | int](m DB, id ID) (*T, error)
- func BySQL[T any](m DB, query string, args ...any) (*T, error)
- func CountQuery(m DB, table string, query string, args ...any) (int, error)
- func DeleteByID[ID string | int](m DB, table string, id ID) error
- func DeleteBySQL(m DB, table string, query string, args ...any) error
- func Exists[ID string | int](m DB, table string, id ID) (bool, error)
- func ExistsBySQL(m DB, table string, query string, args ...any) (bool, error)
- func ForceRunInTx(m DB, fn func(tx TxContext) error) error
- func Insert[T any](m DB, row *T) error
- func InsertMany[T any](m DB, rows []T) error
- func Many[T any](m DB, query string, args ...any) ([]T, error)
- func RunInLockedTx(m DB, id string, fn func(tx TxContext) error) error
- func RunInTx(m DB, fn func(tx TxContext) error) error
- func StructByID[T any, ID string | int](m DB, table string, id ID) (*T, error)
- func StructBySQL[T any](m DB, table string, query string, args ...any) (*T, error)
- func TypeByID[T any, ID string | int](m DB, table string, column string, id ID) (*T, error)
- func TypeBySQL[T any](m DB, table string, column string, query string, args ...any) (*T, error)
- func Update[T any](m DB, row *T, pk ...string) error
- func UpdateSQLByID[ID string | int](m DB, table string, id ID, query string, args ...any) error
- func Upsert[T any](m DB, rows T, conflictColumns string) error
- func UpsertIgnore[T any](m DB, rows T) error
- type Context
- func (m Context) Context() context.Context
- func (m Context) ForceRunInTx(fn func(tx TxContext) error) error
- func (m Context) NewDelete() *bun.DeleteQuery
- func (m Context) NewInsert() *bun.InsertQuery
- func (m Context) NewMerge() *bun.MergeQuery
- func (m Context) NewRaw(query string, args ...any) *bun.RawQuery
- func (m Context) NewSelect() *bun.SelectQuery
- func (m Context) NewUpdate() *bun.UpdateQuery
- func (m Context) NewValues(model any) *bun.ValuesQuery
- func (m Context) RunInTx(fn func(tx TxContext) error) error
- type DB
- type TxContext
- func (m TxContext) Context() context.Context
- func (m TxContext) ForceRunInTx(fn func(tx TxContext) error) error
- func (m TxContext) NewDelete() *bun.DeleteQuery
- func (m TxContext) NewInsert() *bun.InsertQuery
- func (m TxContext) NewMerge() *bun.MergeQuery
- func (m TxContext) NewRaw(query string, args ...any) *bun.RawQuery
- func (m TxContext) NewSelect() *bun.SelectQuery
- func (m TxContext) NewUpdate() *bun.UpdateQuery
- func (m TxContext) NewValues(model any) *bun.ValuesQuery
- func (m TxContext) RunInTx(fn func(tx TxContext) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertMany ¶
func StructBySQL ¶
func UpdateSQLByID ¶
func Upsert ¶
Upsert inserts or updates rows based on conflict columns. To upsert and check multiple constraints, see https://stackoverflow.com/questions/35888012/use-multiple-conflict-target-in-on-conflict-clause
func UpsertIgnore ¶
Types ¶
type Context ¶
func (Context) NewDelete ¶
func (m Context) NewDelete() *bun.DeleteQuery
func (Context) NewInsert ¶
func (m Context) NewInsert() *bun.InsertQuery
func (Context) NewMerge ¶
func (m Context) NewMerge() *bun.MergeQuery
func (Context) NewSelect ¶
func (m Context) NewSelect() *bun.SelectQuery
func (Context) NewUpdate ¶
func (m Context) NewUpdate() *bun.UpdateQuery
type DB ¶
type DB interface {
Context() context.Context
NewSelect() *bun.SelectQuery
NewInsert() *bun.InsertQuery
NewUpdate() *bun.UpdateQuery
NewDelete() *bun.DeleteQuery
NewMerge() *bun.MergeQuery
NewRaw(string, ...any) *bun.RawQuery
NewValues(model any) *bun.ValuesQuery
RunInTx(fn func(tx TxContext) error) error
ForceRunInTx(fn func(tx TxContext) error) error
}
type TxContext ¶
func (TxContext) NewDelete ¶
func (m TxContext) NewDelete() *bun.DeleteQuery
func (TxContext) NewInsert ¶
func (m TxContext) NewInsert() *bun.InsertQuery
func (TxContext) NewMerge ¶
func (m TxContext) NewMerge() *bun.MergeQuery
func (TxContext) NewSelect ¶
func (m TxContext) NewSelect() *bun.SelectQuery
func (TxContext) NewUpdate ¶
func (m TxContext) NewUpdate() *bun.UpdateQuery
Click to show internal directories.
Click to hide internal directories.