Documentation
¶
Overview ¶
Package sqlc is a scaffold for integrating SQLC-generated query code with the go-core database infrastructure.
SCAFFOLD STATUS: The Querier interface and Queries struct below are intentionally empty placeholders. To activate this package:
- Define your SQL queries in database/queries/*.sql
- Run `sqlc generate` from the repository root (see sqlc.yaml)
- Replace the empty Querier interface with the generated sqlc.Querier
- Replace the Queries stub with the generated sqlc.Queries struct
Until those steps are complete, NewFromTx returns an empty Querier that cannot execute any real queries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Querier ¶
type Querier interface {
}
Querier is the minimal interface that generated *Queries structs implement.
func NewFromTx ¶
NewFromTx returns a Querier backed by the given SQL transaction. NOTE: scaffold implementation — returns an empty Queries struct. Replace with the sqlc-generated version after running `sqlc generate`.
func QuerierFromContext ¶
QuerierFromContext retrieves a Querier from the context if present. If a Querier is not directly present, this will attempt to retrieve a *sql.Tx from the context (stored by database.Transactor) and construct a Querier using NewFromTx.
type Queries ¶
type Queries struct{}
Queries is a placeholder. Replace with the sqlc-generated Queries struct after running `sqlc generate`. See package doc in sqlc.go.
type SQLCRepository ¶
type SQLCRepository struct {
Queries Querier
Transactor database.Transactor
}
SQLCRepository is a minimal base repository for sqlc-generated Querier implementations. It holds a Querier and an optional Transactor used to run operations inside transactions.
func NewSQLCRepository ¶
func NewSQLCRepository(q Querier, t database.Transactor) *SQLCRepository
NewSQLCRepository constructs a new SQLCRepository.
func (*SQLCRepository) WithinTransaction ¶
func (r *SQLCRepository) WithinTransaction(ctx context.Context, fn func(ctx context.Context, q Querier) error) error
WithinTransaction executes fn within a transaction if a Transactor is provided. If the Transactor stored a Querier in the context (via sqlc.WithQuerier), prefer that Querier; otherwise fall back to the repository's Queries instance.