db

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecInTransactionContext added in v0.0.7

func ExecInTransactionContext[T any](ctx context.Context, cf IConnectionFactory, tsf TransactionScopeFunction[T]) (T, error)

func ExecStatement

func ExecStatement(connectionFactory IConnectionFactory, sql string, args ...any) chan async.ActionResult[EffectedRows]

func ExecStatementTx

func ExecStatementTx(tx *sql.Tx, sql string, args ...any) chan async.ActionResult[EffectedRows]

func QuerySingle

func QuerySingle[T any](connectionFactory IConnectionFactory, resultMapper ResultMapper[T], sql string, args ...any) chan async.ActionResult[T]

func QuerySingleTx

func QuerySingleTx[T any](tx *sql.Tx, resultMapper ResultMapper[T], sql string, args ...any) chan async.ActionResult[T]

func QueryStatement

func QueryStatement[T any](connectionFactory IConnectionFactory, resultMapper ResultMapper[T], sql string, args ...any) chan async.ActionResult[[]T]

func QueryStatementTx

func QueryStatementTx[T any](tx *sql.Tx, resultMapper ResultMapper[T], sql string, args ...any) chan async.ActionResult[[]T]

Types

type ConnectionFactory

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

func (*ConnectionFactory) GetConnection

func (f *ConnectionFactory) GetConnection(ctx context.Context) (*sql.Conn, error)

GetConnection implements IConnectionFactory.

func (*ConnectionFactory) GetTransaction

func (f *ConnectionFactory) GetTransaction(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

GetTransaction implements IConnectionFactory.

type DbConnectionError

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

func NewDbConnectionError

func NewDbConnectionError(msg string, err error) *DbConnectionError

func (*DbConnectionError) Error

func (e *DbConnectionError) Error() string

type EffectedRows

type EffectedRows int

func EffectedRowsMapper

func EffectedRowsMapper() ([]any, *EffectedRows)

type IConnectionFactory

type IConnectionFactory interface {
	GetConnection(ctx context.Context) (*sql.Conn, error)
	GetTransaction(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

func NewConnectionFactory

func NewConnectionFactory(connectionString, driver string) IConnectionFactory

type ResultMapper

type ResultMapper[T any] func() ([]any, *T)

type TransactionScopeFunction added in v0.0.7

type TransactionScopeFunction[T any] func(ctx context.Context, tx *sql.Tx) (T, error)

Jump to

Keyboard shortcuts

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