Documentation ¶
Index ¶
- func DoesSchemaExist(ctx context.Context, conn PgxIface, schema string) (bool, error)
- func GetTableColumns(ctx context.Context, conn PgxIface, table string) (cols []string, err error)
- func Init(ctx context.Context, db PgxPoolIface, init ConnInitCallback) error
- func MarshallParamToJSONB(v any) any
- func Ping(ctx context.Context, connStr string) error
- type ConnConfigCallback
- type ConnInitCallback
- type PgxConnIface
- type PgxIface
- type PgxPoolIface
- type Querier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoesSchemaExist ¶
DoesSchemaExist checks if schema exists
func GetTableColumns ¶
GetTableColumns returns the list of columns for a given table
func Init ¶
func Init(ctx context.Context, db PgxPoolIface, init ConnInitCallback) error
Init creates a new pool, check connection is establised. If not retries connection 3 times with delay 1s
func MarshallParamToJSONB ¶
Types ¶
type ConnConfigCallback ¶
type PgxConnIface ¶
type PgxConnIface interface { PgxIface BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) Close(ctx context.Context) error Ping(ctx context.Context) error }
PgxConnIface is interface representing pgx connection
type PgxIface ¶
type PgxIface interface { Begin(ctx context.Context) (pgx.Tx, error) Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error) QueryRow(context.Context, string, ...interface{}) pgx.Row Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) }
PgxIface is common interface for every pgx class
type PgxPoolIface ¶
type PgxPoolIface interface { PgxIface Acquire(ctx context.Context) (*pgxpool.Conn, error) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) Close() Config() *pgxpool.Config Ping(ctx context.Context) error Stat() *pgxpool.Stat }
PgxPoolIface is interface representing pgx pool
func New ¶
func New(ctx context.Context, connStr string, callbacks ...ConnConfigCallback) (PgxPoolIface, error)
New create a new pool
func NewWithConfig ¶
func NewWithConfig(ctx context.Context, connConfig *pgxpool.Config, callbacks ...ConnConfigCallback) (PgxPoolIface, error)
NewWithConfig creates a new pool with a given config
Click to show internal directories.
Click to hide internal directories.