Documentation
¶
Overview ¶
Package repository provides bounded, typed database/sql query primitives for application-owned and generated repositories.
Index ¶
- Constants
- Variables
- type Decoder
- type Query
- func (query *Query[T]) ID() string
- func (query *Query[T]) List(ctx context.Context, executor data.Executor, args ...any) ([]T, error)
- func (query *Query[T]) Module() string
- func (query *Query[T]) One(ctx context.Context, executor data.Executor, args ...any) (T, error)
- func (query *Query[T]) Optional(ctx context.Context, executor data.Executor, args ...any) (value T, found bool, err error)
- type QuerySpec
- type Scanner
Constants ¶
View Source
const ( // DefaultMaxRows is the recommended list bound for generated repositories. DefaultMaxRows = 1_000 // MaxRows is the largest list bound accepted by NewQuery. MaxRows = 100_000 )
Variables ¶
View Source
var ( // ErrNotFound indicates that a required single-row query returned no rows. ErrNotFound = errors.New("repository query returned no rows") // ErrMultipleRows indicates that a single-row query returned more than one row. ErrMultipleRows = errors.New("repository query returned multiple rows") // ErrRowLimitExceeded indicates that a list query produced more than its // declared in-memory result bound. ErrRowLimitExceeded = errors.New("repository query row limit exceeded") )
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query[T any] struct { // contains filtered or unexported fields }
Query is an immutable, typed repository query safe for concurrent use when its decoder is safe for concurrent use.
func (*Query[T]) List ¶
func (query *Query[T]) List( ctx context.Context, executor data.Executor, args ...any, ) ([]T, error)
List returns rows in driver order. It rejects the result before decoding any row beyond MaxRows. Callers should also bound work in SQL so the database does not produce an unnecessarily large result.
Click to show internal directories.
Click to hide internal directories.