pgrepo

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package pgrepo is the bell's SQL adapter over the notification table.

Column contract: the adapter reads and writes the columns defined by framework migration 009 — user_id, workspace_id, type, title, body, link (legacy but referenced by every INSERT/SELECT here), dedup_key, once_per_month, read_at, created_at. Framework-table columns are framework-contract surface: product migrations must deprecate unused columns in product code but must NOT drop them — this SQL (and future framework migrations) references them (orkome field report #5: a product that retired link in its own code could not drop the column). Evolving the contract itself is a framework-side change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

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

func New

func New(pool *pgxpool.Pool) *Repo

func (*Repo) Allowed

func (r *Repo) Allowed(ctx context.Context, userID, typ string) (bool, error)

func (*Repo) Archive

func (r *Repo) Archive(ctx context.Context, userID, notificationID string) error

func (*Repo) DeleteAged added in v0.4.1

func (r *Repo) DeleteAged(ctx context.Context, archivedTTL, readTTL time.Duration, batch int) (int64, error)

DeleteAged prunes expired notifications in batches (F8-4): archived rows older than archivedTTL and read-but-not-archived rows older than readTTL. Unread rows are never deleted — they are still the user's pending signal. Returns the number of rows deleted (batch-capped; run to a zero return or on the next tick to drain a large backlog).

func (*Repo) EmailAllowed

func (r *Repo) EmailAllowed(ctx context.Context, userID, typ string) (bool, error)

func (*Repo) Insert

func (r *Repo) Insert(ctx context.Context, n app.NotifyInput, now time.Time) (bool, error)

func (*Repo) List

func (r *Repo) List(ctx context.Context, userID string) ([]app.Preference, error)

func (*Repo) ListInbox

func (r *Repo) ListInbox(ctx context.Context, userID, workspaceID string, limit int) ([]app.Notification, error)

func (*Repo) MarkAllRead

func (r *Repo) MarkAllRead(ctx context.Context, userID string) error

func (*Repo) MarkRead

func (r *Repo) MarkRead(ctx context.Context, userID, notificationID string) error

func (*Repo) UnreadCount

func (r *Repo) UnreadCount(ctx context.Context, userID, workspaceID string) (int, error)

func (*Repo) Upsert

func (r *Repo) Upsert(ctx context.Context, userID, typ string, email, inApp *bool) (app.Preference, error)

Jump to

Keyboard shortcuts

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