postgres

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

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

It is ported from go-licencias' audit_postgres.go rather than go-crucible's or go-bluprint's: go-licencias' List runs a single query using count(*) OVER() to get the total alongside the page of results, instead of the two round trips (one COUNT(*), one SELECT) the other two systems each issue; and go-licencias types the resource-ID filter as *uuid.UUID instead of a bare string, so an invalid ID is rejected by the caller's own parsing instead of silently matching zero rows deep inside a query.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository implements audit.Repository using pgxpool.

func NewRepository

func NewRepository(pool *pgxpool.Pool) *Repository

NewRepository creates a new PostgreSQL-backed audit repository.

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, db pgxtx.DBTX, entry *audit.Entry) error

Create inserts an audit entry using the given db (either a live pgx.Tx or the pool itself — see vogel/pgxtx.DBTX).

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, id uuid.UUID) (*audit.Entry, error)

GetByID retrieves a single audit entry by its primary key.

func (*Repository) List

func (r *Repository) List(ctx context.Context, f audit.Filters) ([]audit.Entry, int, error)

List returns a filtered, paginated slice of audit entries plus the total matching count, using a single SQL statement with count(*) OVER()::INT instead of a separate COUNT(*) round trip.

Jump to

Keyboard shortcuts

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