Documentation
¶
Overview ¶
Package db holds shared low-level database abstractions used across the GoFastr framework subpackages. Splitting this out lets slow_query, eager loading, and the CRUD handler all share the same Executor interface without depending on each other.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TxFromContext ¶
TxFromContext returns the active *sql.Tx from context when a CRUD handler has wrapped the operation in a transaction. Lifecycle hooks may use it to perform additional database work that is atomic with the parent operation — queries the hook runs through the tx see (and only commit with) the parent write.
Types ¶
type Beginner ¶
Beginner is satisfied by *sql.DB. *sql.Tx does not satisfy it, which lets inTx skip nested begin attempts.
type Executor ¶
type Executor interface {
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
Executor is the interface for database operations. Both *sql.DB and *sql.Tx satisfy it; wrappers (e.g. SlowQueryLogger) implement it by delegating to an inner Executor.