postgres

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package postgres provides the PostgreSQL-backed implementation of the document.Repository port, built on native pgx.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository struct{}

Repository implements document.Repository using pgx. It is stateless: every method receives the pgxtx.DBTX to run against, so the caller decides whether to use a plain pool connection or an existing transaction.

func NewRepository

func NewRepository() *Repository

NewRepository creates a stateless PostgreSQL-backed document repository.

func (*Repository) ExistsForCase

func (r *Repository) ExistsForCase(ctx context.Context, db pgxtx.DBTX, caseID uuid.UUID, templateName string) (bool, error)

ExistsForCase reports whether caseID has a document of templateName.

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, db pgxtx.DBTX, id uuid.UUID) (*document.Document, error)

GetByID retrieves a single document by its primary key.

func (*Repository) GetBySourceKey

func (r *Repository) GetBySourceKey(ctx context.Context, db pgxtx.DBTX, key string) (*document.Document, error)

GetBySourceKey retrieves the document whose source key is key. An empty key never matches: documents stored without one have a NULL source_key.

func (*Repository) GetByVerificationKey

func (r *Repository) GetByVerificationKey(ctx context.Context, db pgxtx.DBTX, key string) (*document.Document, error)

GetByVerificationKey retrieves the document whose verification key is key.

func (*Repository) Insert

func (r *Repository) Insert(ctx context.Context, db pgxtx.DBTX, d *document.Document) error

Insert persists d; an empty SourceKey is stored as NULL. A duplicate id, storage key, verification key or non-empty source key is returned as the driver's unique-violation error, wrapped.

func (*Repository) ListByCase

func (r *Repository) ListByCase(ctx context.Context, db pgxtx.DBTX, caseID uuid.UUID) ([]document.Document, error)

ListByCase returns every document of caseID ordered by created_at, then id, ascending.

Jump to

Keyboard shortcuts

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