Documentation ¶
Index ¶
- Constants
- Variables
- func CheckCreateError(err error) error
- func CheckDeleteError(err error) error
- func CheckListError(err error) error
- func CheckReadError(err error) error
- func CheckUpdateError(err error) error
- func Connect(uri string) (*pgx.Conn, error)
- func ConnectPool(uri string) (*pgxpool.Pool, error)
- func Migrate(conn Conn, files fs.FS) ([]string, error)
- type Conn
Constants ¶
View Source
const Timeout = 3 * time.Second
default query timeout
Variables ¶
View Source
var ( ErrNotFound = errors.New("postgres: not found") ErrConflict = errors.New("postgres: conflict") // sentinel error used to rollback transactions ErrRollback = errors.New("postgres: rollback") )
TODO: add metadata to errors to make em more useful:
- what already exists
- what was missing
- what column(s) caused the conflict
Functions ¶
func CheckCreateError ¶
func CheckDeleteError ¶
func CheckListError ¶
func CheckReadError ¶
func CheckUpdateError ¶
Types ¶
type Conn ¶
type Conn interface { Begin(ctx context.Context) (pgx.Tx, error) Exec(ctx context.Context, sql string, args ...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 }
Common interface for pgx.Conn, pgx.Pool, pgx.Tx, etc https://github.com/jackc/pgx/issues/644
Click to show internal directories.
Click to hide internal directories.