Documentation
¶
Index ¶
- type Converter
- type ProtoRepository
- func (r *ProtoRepository[T, C, S, P]) Converter() Converter[S, P]
- func (r *ProtoRepository[T, C, S, P]) Execute(ctx context.Context, query types.Buildable) (int64, error)
- func (r *ProtoRepository[T, C, S, P]) Query(ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S]) ([]P, error)
- func (r *ProtoRepository[T, C, S, P]) QueryRow(ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S]) (P, error)
- func (r *ProtoRepository[T, C, S, P]) Scanner() *ScannerRepository[T, C, S]
- func (r *ProtoRepository[T, C, S, P]) WithDB(db exec.DB) *ProtoRepository[T, C, S, P]
- type ScannerRepository
- func (r *ScannerRepository[T, C, S]) DB() exec.DB
- func (r *ScannerRepository[T, C, S]) Execute(ctx context.Context, query types.Buildable) (int64, error)
- func (r *ScannerRepository[T, C, S]) Query(ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S]) ([]S, error)
- func (r *ScannerRepository[T, C, S]) QueryRow(ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S]) (S, error)
- func (r *ScannerRepository[T, C, S]) Table() *schema.Table[T, C, S]
- func (r *ScannerRepository[T, C, S]) WithDB(db exec.DB) *ScannerRepository[T, C, S]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter[S, P any] struct { ToScanner func(P) S ToProto func(S) P }
Converter - функции конвертации между Scanner и Proto типами
type ProtoRepository ¶
type ProtoRepository[T types.TableAlias, C types.ColumnAlias, S exec.Scanner[C], P any] struct { // contains filtered or unexported fields }
ProtoRepository provides query operations with automatic proto <-> scanner conversion
func NewProtoRepository ¶
func NewProtoRepository[T types.TableAlias, C types.ColumnAlias, S exec.Scanner[C], P any]( scanner *ScannerRepository[T, C, S], converter Converter[S, P], ) *ProtoRepository[T, C, S, P]
NewProtoRepository creates a new ProtoRepository
func (*ProtoRepository[T, C, S, P]) Converter ¶
func (r *ProtoRepository[T, C, S, P]) Converter() Converter[S, P]
Converter returns the converter for manual conversions
func (*ProtoRepository[T, C, S, P]) Execute ¶
func (r *ProtoRepository[T, C, S, P]) Execute(ctx context.Context, query types.Buildable) (int64, error)
Execute executes a non-select query and returns affected rows
func (*ProtoRepository[T, C, S, P]) Query ¶
func (r *ProtoRepository[T, C, S, P]) Query( ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S], ) ([]P, error)
Query executes a select query and returns results as proto slice
func (*ProtoRepository[T, C, S, P]) QueryRow ¶
func (r *ProtoRepository[T, C, S, P]) QueryRow( ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S], ) (P, error)
QueryRow executes a select query and returns a single result as proto
func (*ProtoRepository[T, C, S, P]) Scanner ¶
func (r *ProtoRepository[T, C, S, P]) Scanner() *ScannerRepository[T, C, S]
Scanner returns the underlying ScannerRepository for complex operations
func (*ProtoRepository[T, C, S, P]) WithDB ¶
func (r *ProtoRepository[T, C, S, P]) WithDB(db exec.DB) *ProtoRepository[T, C, S, P]
WithDB returns a new ProtoRepository with a different DB (useful for transactions)
type ScannerRepository ¶
type ScannerRepository[T types.TableAlias, C types.ColumnAlias, S exec.Scanner[C]] struct { // contains filtered or unexported fields }
ScannerRepository provides CRUD operations for scanner types
func NewScannerRepository ¶
func NewScannerRepository[T types.TableAlias, C types.ColumnAlias, S exec.Scanner[C]]( table *schema.Table[T, C, S], db exec.DB, ) *ScannerRepository[T, C, S]
NewScannerRepository creates a new ScannerRepository
func (*ScannerRepository[T, C, S]) DB ¶
func (r *ScannerRepository[T, C, S]) DB() exec.DB
DB returns the underlying database connection
func (*ScannerRepository[T, C, S]) Execute ¶
func (r *ScannerRepository[T, C, S]) Execute(ctx context.Context, query types.Buildable) (int64, error)
Execute executes a non-select query (INSERT, UPDATE, DELETE) and returns affected rows
func (*ScannerRepository[T, C, S]) Query ¶
func (r *ScannerRepository[T, C, S]) Query( ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S], ) ([]S, error)
Query executes a select query and returns multiple results
func (*ScannerRepository[T, C, S]) QueryRow ¶
func (r *ScannerRepository[T, C, S]) QueryRow( ctx context.Context, query types.Scannable, opts ...exec.QueryOption[C, S], ) (S, error)
QueryRow executes a select query and returns a single result
func (*ScannerRepository[T, C, S]) Table ¶
func (r *ScannerRepository[T, C, S]) Table() *schema.Table[T, C, S]
Table returns the underlying schema.Table for building custom queries
func (*ScannerRepository[T, C, S]) WithDB ¶
func (r *ScannerRepository[T, C, S]) WithDB(db exec.DB) *ScannerRepository[T, C, S]
WithDB returns a new ScannerRepository with a different DB (useful for transactions)