exec

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadRelations

func LoadRelations(ctx context.Context) bool

func SkipRelations

func SkipRelations(ctx context.Context) bool

func WithRelations

func WithRelations(ctx context.Context) context.Context

func WithSkipRelations

func WithSkipRelations(ctx context.Context) context.Context

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 RelationLoader[S any] interface {
	Load(ctx context.Context, db DB, base S) error
}

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]) CopyFrom

func (t *TableExecutor[T, C, S]) CopyFrom(ctx context.Context, db DB, values []S, fields ...C) (int64, error)

func (*TableExecutor[T, C, S]) Execute

func (t *TableExecutor[T, C, S]) Execute(ctx context.Context, db DB, query types.Buildable) (int64, error)

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL