Documentation ¶
Index ¶
- Variables
- func Exec(ctx TxContext, query string, args ...any) (int64, error)
- func Query[T any](ctx TxContext, query string, binder func(*T) []any, args ...any) ([]T, error)
- func QueryRow[T any](ctx TxContext, query string, binder func(*T) []any, args ...any) (T, error)
- type Access
- type Connector
- type CtxDataSourceKey
- type NotFoundError
- type Null
- func (n Null[T]) Equal(other Null[T]) bool
- func (n Null[T]) IsZero() bool
- func (n Null[T]) MarshalJSON() ([]byte, error)
- func (n Null[T]) Ptr() *T
- func (n *Null[T]) Scan(value any) error
- func (n *Null[T]) SetValid(v T)
- func (n *Null[T]) UnmarshalJSON(data []byte) error
- func (n Null[T]) Value() (driver.Value, error)
- func (n Null[T]) ValueOrZero() T
- type Number
- type Tx
- func (t *Tx) Commit() error
- func (t *Tx) Exec(query string, args ...any) (sql.Result, error)
- func (t *Tx) Prepare(query string) (*sql.Stmt, error)
- func (t *Tx) Query(query string, args ...any) (*sql.Rows, error)
- func (t *Tx) QueryRow(query string, args ...any) *sql.Row
- func (t *Tx) Rollback() error
- func (t *Tx) WithValue(key, value any) TxContext
- type TxContext
- type TxProvider
- func (t *TxProvider) Acquire(ctx context.Context) (*Tx, error)
- func (t *TxProvider) AcquireWithOpts(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (t *TxProvider) Tx(ctx context.Context, fn func(TxContext) error) error
- func (t *TxProvider) TxWithOpts(ctx context.Context, fn func(TxContext) error, opts *sql.TxOptions) error
- type Type
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTxOpts = sql.TxOptions{ Isolation: sql.LevelDefault, ReadOnly: false, }
DefaultTxOpts is package variable with default transaction level
Functions ¶
Types ¶
type Access ¶
type Access interface { PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row }
Access interface for simple DML operations.
type CtxDataSourceKey ¶
type CtxDataSourceKey struct{} // Datasource context key, useful only error handling
type NotFoundError ¶
type NotFoundError struct {
DataSource string
}
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Null ¶
Null is generic type which can be nullable..
func (Null[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Null[T]) Ptr ¶
func (n Null[T]) Ptr() *T
Ptr returns a pointer to this T value, or a nil pointer if Val is null.
func (*Null[T]) SetValid ¶
func (n *Null[T]) SetValid(v T)
SetValid changes this T value and also sets it to be non-null.
func (*Null[T]) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (Null[T]) ValueOrZero ¶
func (n Null[T]) ValueOrZero() T
ValueOrZero returns the inner value if valid, otherwise false.
type Tx ¶
Tx represents transaction with context as inner object.
type TxContext ¶
type TxContext interface { context.Context WithValue(key, value any) TxContext Prepare(query string) (*sql.Stmt, error) Exec(query string, args ...any) (sql.Result, error) Query(query string, args ...any) (*sql.Rows, error) QueryRow(query string, args ...any) *sql.Row }
TxContext interface for DAO operations with context.
type TxProvider ¶
type TxProvider struct {
// contains filtered or unexported fields
}
TxProvider ...
func (*TxProvider) Acquire ¶
func (t *TxProvider) Acquire(ctx context.Context) (*Tx, error)
Acquire transaction from db
func (*TxProvider) AcquireWithOpts ¶
AcquireWithOpts transaction from db
func (*TxProvider) TxWithOpts ¶
func (t *TxProvider) TxWithOpts(ctx context.Context, fn func(TxContext) error, opts *sql.TxOptions) error
TxWithOpts ...
Click to show internal directories.
Click to hide internal directories.