Documentation
¶
Index ¶
- Variables
- func ClassifyStatement(statement string) (operation string, target string)
- func NewNoop() *noopDB
- func WithTx(ctx context.Context, tx Tx) context.Context
- type BatchInsert
- type BatchStatement
- type DB
- type Dialect
- type Option
- type Options
- type Page
- type Query
- type QueryHook
- type QueryHookFuncs
- type QueryMetadata
- type Result
- type Row
- type Rows
- type Stmt
- type Tx
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidBatch = errors.New("invalid sql batch insert")
View Source
var ErrNotConfigured = errors.New("sql not configured")
Functions ¶
func ClassifyStatement ¶
Types ¶
type BatchInsert ¶
type BatchStatement ¶
func BuildBatchInsertStatements ¶
func BuildBatchInsertStatements(batch BatchInsert) ([]BatchStatement, error)
type DB ¶
type DB interface {
Exec(ctx context.Context, query string, args ...any) (Result, error)
Query(ctx context.Context, query string, args ...any) (Rows, error)
QueryRow(ctx context.Context, query string, args ...any) Row
Prepare(ctx context.Context, query string) (Stmt, error)
Begin(ctx context.Context) (Tx, error)
WithTransaction(ctx context.Context, fn func(context.Context, Tx) error) error
BatchInsert(ctx context.Context, batch BatchInsert) (Result, error)
}
type Options ¶
func NewOptions ¶
type QueryHook ¶
type QueryHook interface {
BeforeQuery(ctx context.Context, metadata QueryMetadata) context.Context
AfterQuery(ctx context.Context, metadata QueryMetadata)
}
type QueryHookFuncs ¶
type QueryHookFuncs struct {
Before func(ctx context.Context, metadata QueryMetadata) context.Context
After func(ctx context.Context, metadata QueryMetadata)
}
func (QueryHookFuncs) AfterQuery ¶
func (h QueryHookFuncs) AfterQuery(ctx context.Context, metadata QueryMetadata)
func (QueryHookFuncs) BeforeQuery ¶
func (h QueryHookFuncs) BeforeQuery(ctx context.Context, metadata QueryMetadata) context.Context
type QueryMetadata ¶
type QueryMetadata struct {
Name string
Driver string
Operation string
Target string
Statement string
Args []any
BatchRows int
InTransaction bool
RowsAffected int64
LastInsertID int64
StartedAt time.Time
Duration time.Duration
Err error
}
func MetadataForQuery ¶
func MetadataForQuery(name string, driver string, statement string, args ...any) QueryMetadata
func (QueryMetadata) Clone ¶
func (m QueryMetadata) Clone() QueryMetadata
type Tx ¶
type Tx interface {
Exec(ctx context.Context, query string, args ...any) (Result, error)
Query(ctx context.Context, query string, args ...any) (Rows, error)
QueryRow(ctx context.Context, query string, args ...any) Row
Prepare(ctx context.Context, query string) (Stmt, error)
Commit() error
Rollback() error
}
Click to show internal directories.
Click to hide internal directories.