Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultBatchItemsMaxSize = 500 DefaultSchemaName = "public" TimeLayoutISO = "2006-01-02 15:04:05" )
View Source
const ( Serializable = TxIsoLevel("serializable") RepeatableRead = TxIsoLevel("repeatable read") ReadCommitted = TxIsoLevel("read committed") ReadUncommitted = TxIsoLevel("read uncommitted") )
Transaction isolation levels
View Source
const ( ReadWrite = TxAccessMode("read write") ReadOnly = TxAccessMode("read only") )
Transaction access modes
View Source
const ( Deferrable = TxDeferrableMode("deferrable") NotDeferrable = TxDeferrableMode("not deferrable") )
Transaction deferrable modes
Variables ¶
View Source
var ErrNoRows = pgx.ErrNoRows
Functions ¶
This section is empty.
Types ¶
type BatchItem ¶
type BatchItem interface { SetQuery(query string) SetArgs(args ...any) GetQuery() string GetArgs() []any }
func NewBatchItem ¶
func NewBatchItem() BatchItem
type Client ¶
type Client interface { ClientReader ClientWriter }
type ClientReader ¶
func NewReader ¶
func NewReader(cfg *Config) (ClientReader, error)
type ClientWriter ¶
type ClientWriter interface { Writer Pool BeginTx(ctx context.Context, opts TxOptions) (Transaction, error) }
func NewWriter ¶
func NewWriter(cfg *Config) (ClientWriter, error)
type PgxConn ¶
type PgxConn interface { // Release returns c to the pool it was acquired from. Once Release has been called, other methods must not be called. // However, it is safe to call Release multiple times. Subsequent calls after the first will be ignored. Release() 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 QueryFunc(ctx context.Context, sql string, args []any, scans []any, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) Begin(ctx context.Context) (pgx.Tx, error) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error Ping(ctx context.Context) error Conn() *pgx.Conn }
type Reader ¶
type Reader interface { QueryRow(ctx context.Context, query string, args ...any) (Row, error) QueryRows(ctx context.Context, conn PgxConn, query string, args ...any) (Rows, error) CountRows(ctx context.Context, query string, args ...any) (int, error) TruncateTables(ctx context.Context, tables []string) error }
type Rows ¶
type Rows interface { // Close closes the rows, making the connection ready for use again. It is safe // to call Close after rows is already closed. Close() // Err returns any error that occurred while reading. Err() error // Next prepares the next row for reading. It returns true if there is another // row and false if no more rows are available. It automatically closes rows // when all rows are read. Next() bool // Scan reads the values from the current row into dest values positionally. // dest can include pointers to core types, values implementing the Scanner // interface, and nil. nil will skip the value entirely. Scan(dest ...any) error // Values returns the decoded row values. Values() ([]any, error) // RawValues returns the unparsed bytes of the row values. The returned [][]byte is only valid until the Next // call or the Rows is closed. However, the underlying byte data is safe to retain a reference to and mutate. RawValues() [][]byte }
type Transaction ¶
type TxAccessMode ¶
type TxAccessMode string
type TxDeferrableMode ¶
type TxDeferrableMode string
type TxIsoLevel ¶
type TxIsoLevel string
type TxOptions ¶
type TxOptions struct { IsoLevel TxIsoLevel AccessMode TxAccessMode DeferrableMode TxDeferrableMode }
type Writer ¶
type Writer interface { InsertRow(ctx context.Context, query string, args ...interface{}) (uuid.UUID, error) InsertRowWithStringID(ctx context.Context, query string, args ...interface{}) (string, error) UpdateRowByID(ctx context.Context, sqlData map[string]interface{}, schemaName, tableName, id string) error SendBatch(ctx context.Context, batch Batch) error ExecuteQuery(ctx context.Context, query string, args ...interface{}) error TruncateTables(ctx context.Context, tables []string) error }
Click to show internal directories.
Click to hide internal directories.