store

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package store provides shared Postgres helpers used across paper-board services. The primary entry is WithTx, a generic transaction wrapper that composes pgx.Tx semantics with strongly-typed return values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTx

func WithTx[T any](ctx context.Context, pool *pgxpool.Pool, fn func(pgx.Tx) (T, error)) (T, error)

WithTx runs fn inside a database transaction. It begins a tx before fn is called; commits on nil error; rolls back on any non-nil error or panic. Context cancellation forces rollback. The result of fn is returned on success.

Usage:

res, err := store.WithTx(ctx, pool, func(tx pgx.Tx) (Result, error) {
    if _, err := tx.Exec(ctx, "..."); err != nil {
        return Result{}, err
    }
    return Result{...}, nil
})

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL