sdbun

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package sdbun bun 扩展包

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIllegalDriver = sderr.Sentinel("illegal driver")
)

Functions

func Count

func Count[ROW any](ctx context.Context, db bun.IDB, qfn func(*bun.SelectQuery) *bun.SelectQuery) (int64, error)

func Delete

func Delete[ROW any](ctx context.Context, db bun.IDB, qfn func(query *bun.DeleteQuery) *bun.DeleteQuery) (sdsql.Result, error)

func Dial

func Dial(addr Address, opts ...bun.DBOption) (*bun.DB, error)

func Exists

func Exists[ROW any](ctx context.Context, db bun.IDB, qfn func(*bun.SelectQuery) *bun.SelectQuery) (bool, error)

func Insert

func Insert(ctx context.Context, db bun.IDB, v any, qfn func(query *bun.InsertQuery) *bun.InsertQuery) (sdsql.Result, error)

func LoggerOf

func LoggerOf(name string) bun.QueryHook

func PageApplier

func PageApplier(p sdsql.Page) func(*bun.SelectQuery) *bun.SelectQuery

func SelectFirst

func SelectFirst[ROW any](ctx context.Context, db bun.IDB, qfn func(*bun.SelectQuery) *bun.SelectQuery, postProcs ...sdsql.RowsProc[ROW]) (ROW, error)

func SelectFirstRaw

func SelectFirstRaw[ROW any](ctx context.Context, db bun.IDB, q string, args []any, postProcs ...sdsql.RowsProc[ROW]) (ROW, error)

func SelectMany

func SelectMany[ROW any](ctx context.Context, db bun.IDB, qfn func(*bun.SelectQuery) *bun.SelectQuery, postProcs ...sdsql.RowsProc[ROW]) ([]ROW, error)

func SelectManyAndCount

func SelectManyAndCount[ROW any](ctx context.Context, db bun.IDB, qfn func(*bun.SelectQuery) *bun.SelectQuery, postProcs ...sdsql.RowsProc[ROW]) ([]ROW, int64, error)

func SelectManyRaw

func SelectManyRaw[ROW any](ctx context.Context, db bun.IDB, q string, args []any, postProcs ...sdsql.RowsProc[ROW]) ([]ROW, error)

func SelectMap added in v0.2.1

func SelectMap[ROW any, K comparable, V any](ctx context.Context, db bun.IDB, qfn func(*bun.SelectQuery) *bun.SelectQuery, transform func(ROW) (K, V), postProcs ...sdsql.RowsProc[ROW]) (map[K]V, error)

func SelectMapRaw added in v0.2.1

func SelectMapRaw[ROW any, K comparable, V any](ctx context.Context, db bun.IDB, q string, args []any, transform func(ROW) (K, V), postProcs ...sdsql.RowsProc[ROW]) (map[K]V, error)

func SelectOne

func SelectOne[T any](ctx context.Context, db bun.IDB, q string, args []any) (T, error)

func SelectPage added in v0.2.2

func SelectPage[ROW any](ctx context.Context, db bun.IDB, p sdsql.Page, qfn func(*bun.SelectQuery) *bun.SelectQuery, postProcs ...sdsql.RowsProc[ROW]) (*sdsql.PagingResult[ROW], error)

func Tx added in v0.2.1

func Tx(ctx context.Context, db bun.IDB, action func(context.Context, bun.Tx) error, opts *sql.TxOptions) error

func TxFor added in v0.2.1

func TxFor[R any](ctx context.Context, db bun.IDB, action func(context.Context, bun.Tx) (R, error), opts *sql.TxOptions) (R, error)

func Update

func Update(ctx context.Context, db bun.IDB, v any, qfn func(query *bun.UpdateQuery) *bun.UpdateQuery) (sdsql.Result, error)

Types

type Address

type Address struct {
	// common
	Driver string `json:"driver" toml:"driver" yaml:"driver"`
	DSN    string `json:"dsn" toml:"dsn" yaml:"dsn"`
	Logger string `json:"logger" toml:"logger"`

	// options
	ConnMaxLifeTimeMS int64 `json:"conn_max_lifetime" toml:"conn_max_lifetime" yaml:"conn_max_lifetime"`
	ConnMaxIdleTimeMS int64 `json:"conn_max_idle_time" toml:"conn_max_idle_time" yaml:"conn_max_idle_time"`
	MaxIdleConns      int   `json:"max_idle_conns" toml:"max_idle_conns" yaml:"max_idle_conns"`
	MaxOpenConns      int   `json:"max_open_conns" toml:"max_open_conns" yaml:"max_open_conns"`
}

Jump to

Keyboard shortcuts

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