postgres
import "github.com/prescriptoo/prescriptoo-api/services/patient/internal/adapters/postgres"Package postgres implements Patient-owned PostgreSQL persistence.
Index
- type Repository
- func New(db *pgxpool.Pool) *Repository
- func (r *Repository) Create(ctx context.Context, x *domain.Profile) error
- func (r *Repository) FindRequest(ctx context.Context, user, org, key string) (string, string, error)
- func (r *Repository) Get(ctx context.Context, id, org string, lock bool) (*domain.Profile, error)
- func (r *Repository) List(ctx context.Context, q ports.ListQuery) (*ports.ListPage, error)
- func (r *Repository) NextMRN(ctx context.Context, org string) (string, error)
- func (r *Repository) SaveRequest(ctx context.Context, user, org, key, f, id string, now time.Time) error
- func (r *Repository) Scope(ctx context.Context, id string) (ports.Scope, error)
- func (r *Repository) Update(ctx context.Context, x *domain.Profile, expected int64) error
- type UnitOfWork
type Repository
Repository persists Patient-owned records and retry state.
type Repository struct {
// contains filtered or unexported fields
}func New
func New(db *pgxpool.Pool) *RepositoryNew creates a PostgreSQL patient repository and fails closed without a database.
func (*Repository) Create
func (r *Repository) Create(ctx context.Context, x *domain.Profile) errorCreate inserts a patient profile.
func (*Repository) FindRequest
func (r *Repository) FindRequest(ctx context.Context, user, org, key string) (string, string, error)FindRequest looks up a scoped create retry fingerprint and result.
func (*Repository) Get
func (r *Repository) Get(ctx context.Context, id, org string, lock bool) (*domain.Profile, error)Get reads a profile constrained to its authorized organization.
func (*Repository) List
func (r *Repository) List(ctx context.Context, q ports.ListQuery) (*ports.ListPage, error)List counts and queries authorized rows before applying the keyset boundary.
func (*Repository) NextMRN
func (r *Repository) NextMRN(ctx context.Context, org string) (string, error)NextMRN atomically allocates the next organization-local number.
func (*Repository) SaveRequest
func (r *Repository) SaveRequest(ctx context.Context, user, org, key, f, id string, now time.Time) errorSaveRequest records the committed create result in the business transaction.
func (*Repository) Scope
func (r *Repository) Scope(ctx context.Context, id string) (ports.Scope, error)Scope contains only the stored facts needed to establish patient access.
func (*Repository) Update
func (r *Repository) Update(ctx context.Context, x *domain.Profile, expected int64) errorUpdate persists an effective patch at the expected version.
type UnitOfWork
UnitOfWork commits patient business changes and provider effects atomically.
type UnitOfWork struct{ DB *pgxpool.Pool }func (UnitOfWork) WithinTransaction
func (w UnitOfWork) WithinTransaction(ctx context.Context, fn func(ports.Transaction) error) errorWithinTransaction runs patient persistence and provider effects on one transaction.
Generated by gomarkdoc