Documentation
¶
Index ¶
- func LoadRelations(ctx context.Context) bool
- func SkipRelations(ctx context.Context) bool
- func WithRelations(ctx context.Context) context.Context
- func WithSkipRelations(ctx context.Context) context.Context
- type DB
- type LoadOption
- type QueryConfig
- type QueryOption
- type RelationLoader
- type RelationProvider
- type Scanner
- type TableExecutor
- func (t *TableExecutor[T, C, S]) CopyFrom(ctx context.Context, db DB, values []S, fields ...C) (int64, error)
- func (t *TableExecutor[T, C, S]) Execute(ctx context.Context, db DB, query types.Buildable) (int64, error)
- func (t *TableExecutor[T, C, S]) Query(ctx context.Context, db DB, query types.Scannable, opts ...QueryOption[C, S]) (trgs []S, err error)
- func (t *TableExecutor[T, C, S]) QueryRow(ctx context.Context, db DB, query types.Scannable, opts ...QueryOption[C, S]) (trg S, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadRelations ¶
func SkipRelations ¶
Types ¶
type DB ¶
type DB interface {
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
}
type LoadOption ¶ added in v0.2.0
type LoadOption[C types.ColumnAlias, S Scanner[C]] struct { // contains filtered or unexported fields }
LoadOption реализует QueryOption для загрузки указанных relations
func (*LoadOption[C, S]) ApplyQuery ¶ added in v0.2.0
func (o *LoadOption[C, S]) ApplyQuery(cfg *QueryConfig[C, S])
ApplyQuery implements QueryOption interface
type QueryConfig ¶ added in v0.2.0
type QueryConfig[C types.ColumnAlias, S Scanner[C]] struct { Loaders []RelationLoader[S] }
QueryConfig holds configuration for query execution
type QueryOption ¶ added in v0.2.0
type QueryOption[C types.ColumnAlias, S Scanner[C]] interface { ApplyQuery(*QueryConfig[C, S]) }
QueryOption - типизированная опция для Query/QueryRow
func WithRelationLoaders ¶ added in v0.2.0
func WithRelationLoaders[C types.ColumnAlias, S Scanner[C]]( loaders ...RelationLoader[S], ) QueryOption[C, S]
WithRelationLoaders создаёт опцию из loaders (используется в генерации)
type RelationLoader ¶
type RelationProvider ¶
type RelationProvider[S any] interface { Relations() []RelationLoader[S] }
type Scanner ¶
type Scanner[F types.ColumnAlias] interface { GetTarget(string) func() any GetSetter(F) func() set.ValueSetter[F] GetValue(F) func() any }
type TableExecutor ¶
type TableExecutor[T types.TableAlias, C types.ColumnAlias, S Scanner[C]] struct { // contains filtered or unexported fields }
func NewTableExecutor ¶
func NewTableExecutor[T types.TableAlias, C types.ColumnAlias, S Scanner[C]]( alias T, allFields []C, scanFactory func() S, ) *TableExecutor[T, C, S]
func (*TableExecutor[T, C, S]) Query ¶
func (t *TableExecutor[T, C, S]) Query(ctx context.Context, db DB, query types.Scannable, opts ...QueryOption[C, S]) (trgs []S, err error)
func (*TableExecutor[T, C, S]) QueryRow ¶
func (t *TableExecutor[T, C, S]) QueryRow(ctx context.Context, db DB, query types.Scannable, opts ...QueryOption[C, S]) (trg S, err error)
Click to show internal directories.
Click to hide internal directories.