mirror of
https://github.com/ManyakRus/starter.git
synced 2025-11-26 23:10:42 +02:00
сделал type IConnectionTransaction interface
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/ManyakRus/starter/log"
|
"github.com/ManyakRus/starter/log"
|
||||||
"github.com/ManyakRus/starter/port_checker"
|
"github.com/ManyakRus/starter/port_checker"
|
||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/jackc/pgx/v5/pgconn"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -539,3 +540,22 @@ func Ping_err(ctxMain context.Context) error {
|
|||||||
_, err = Conn.Exec(ctx, ";")
|
_, err = Conn.Exec(ctx, ";")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IConnectionTransaction - интерфейс для работы с базой данных
|
||||||
|
// объединяет в себе функции pgx.Conn, pgxpool.Pool и pgx.Tx
|
||||||
|
// чтобы передавать в функцию любой их них
|
||||||
|
type IConnectionTransaction interface {
|
||||||
|
// Transaction management
|
||||||
|
Begin(ctx context.Context) (pgx.Tx, error)
|
||||||
|
|
||||||
|
// Query execution
|
||||||
|
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
|
||||||
|
|
||||||
|
// Batch operations
|
||||||
|
SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
|
||||||
|
|
||||||
|
// Bulk copy operations
|
||||||
|
CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user