postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package postgres provides a PostgreSQL-backed implementation of refid.SequenceStore using database/sql and raw SQL — no ORM. Import a PostgreSQL driver (e.g. github.com/jackc/pgx/v5/stdlib), open a connection with sql.Open, and pass the resulting *sql.DB to New.

Index

Constants

View Source
const DefaultTableName = "refid_sequences"

DefaultTableName is the default table name used for sequence counters.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, db *sql.DB, opts ...Option) error

Migrate creates the sequence-counter table if it does not already exist. Pass WithTableName to migrate a custom table name.

func New

func New(db *sql.DB, opts ...Option) (refid.SequenceStore, error)

New returns a refid.SequenceStore backed by PostgreSQL. db must already be opened against the pgx driver (see the package doc). By default it targets the "refid_sequences" table; override with WithTableName. New returns an error (never panics) if an option is invalid.

Types

type Option

type Option func(*config)

Option configures optional behavior for a PostgreSQL SequenceStore.

func WithTableName

func WithTableName(name string) Option

WithTableName overrides the default table name ("refid_sequences"). An invalid name (must match [a-zA-Z_][a-zA-Z0-9_]*) is recorded and surfaced as an error from New or Migrate — never a panic.

Jump to

Keyboard shortcuts

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