Documentation
¶
Index ¶
- type Executor
- type TxExecutor
- func (e *TxExecutor) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (e *TxExecutor) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
- func (e *TxExecutor) Query(ctx context.Context, sql string, arguments ...interface{}) (pgx.Rows, error)
- func (e *TxExecutor) QueryRow(ctx context.Context, sql string, arguments ...interface{}) pgx.Row
- func (e *TxExecutor) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
- type TxExecutorOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor interface {
// Exec executes the given SQL statement with the provided arguments in the context of the Executor.
//
// Parameters:
// - ctx: The context.Context object.
// - sql: The SQL statement to execute.
// - arguments: The arguments to be passed to the SQL statement.
//
// Returns:
// - pgconn.CommandTag: The command tag returned by the execution.
// - error: An error if the execution fails.
Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
// Query executes a SQL query with the provided arguments in the context of the Executor.
//
// Parameters:
// - ctx: The context.Context object.
// - sql: The SQL query to execute.
// - arguments: The arguments to be passed to the SQL query.
//
// Returns:
// - pgx.Rows: The result of the query.
// - error: An error if the query execution fails.
Query(ctx context.Context, sql string, arguments ...interface{}) (pgx.Rows, error)
// QueryRow executes a SQL query with the provided arguments in the context of the Executor,
// returning a single row result.
//
// Parameters:
// - ctx: The context.Context object.
// - sql: The SQL query to execute.
// - arguments: The arguments to be passed to the SQL query.
//
// Returns:
// - pgx.Row: The result of the query as a single row.
QueryRow(ctx context.Context, sql string, arguments ...interface{}) pgx.Row
CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
}
type TxExecutor ¶
type TxExecutor struct {
// contains filtered or unexported fields
}
func NewTxExecutor ¶
func NewTxExecutor(defaultTr trmpgx.Tr, options ...TxExecutorOption) *TxExecutor
NewTxExecutor creates a new TxExecutor with the given defaultTr and options.
Parameters: - defaultTr: The default transaction to use. - options: Optional configurations for the TxExecutor.
Returns: - *TxExecutor: The newly created TxExecutor.
func (*TxExecutor) CopyFrom ¶
func (e *TxExecutor) CopyFrom( ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource, ) (int64, error)
func (*TxExecutor) Exec ¶
func (e *TxExecutor) Exec( ctx context.Context, sql string, arguments ...interface{}, ) (pgconn.CommandTag, error)
Exec executes the given SQL statement with the provided arguments in the context of the TxExecutor.
Parameters: - ctx: The context.Context object. - sql: The SQL statement to execute. - arguments: The arguments to be passed to the SQL statement.
Returns: - pgconn.CommandTag: The command tag returned by the execution. - error: An error if the execution fails.
func (*TxExecutor) Query ¶
func (e *TxExecutor) Query( ctx context.Context, sql string, arguments ...interface{}, ) (pgx.Rows, error)
Query executes a SQL query with the provided arguments in the context of the TxExecutor.
Parameters: - ctx: The context.Context object. - sql: The SQL query to execute. - arguments: The arguments to be passed to the SQL query.
Returns: - pgx.Rows: The result of the query. - error: An error if the query execution fails.
func (*TxExecutor) QueryRow ¶
QueryRow executes a SQL query with the provided arguments in the context of the TxExecutor, returning a single row result.
Parameters: - ctx: The context.Context object. - sql: The SQL query to execute. - arguments: The arguments to be passed to the SQL query.
Returns: - pgx.Row: The result of the query as a single row.
func (*TxExecutor) SendBatch ¶
func (e *TxExecutor) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
type TxExecutorOption ¶
type TxExecutorOption func(*TxExecutor)
func WithCtxGetter ¶
func WithCtxGetter(ctxGetter ctxGetter) TxExecutorOption
WithCtxGetter sets the ctxGetter for the TxExecutor.
Parameters: - ctxGetter: The ctxGetter implementation to be used.
Returns: - TxExecutorOption: A function that takes a TxExecutor pointer and sets its ctxGetter field.