Expand description
§Postgres Read Model Store
Implementation of ReadModelStore backed by an sqlx::PgPool. Mirrors
the SQLite store’s contract: every projection table has the standard
projection shape (id TEXT PK, version BIGINT, data JSONB), and writes are
version-gated so replay and at-least-once delivery converge.
§Idempotency
upsert translates to
INSERT INTO {table} (id, version, data) VALUES ($1, $2, $3)
ON CONFLICT (id) DO UPDATE
SET version = EXCLUDED.version, data = EXCLUDED.data
WHERE {table}.version < EXCLUDED.versionApplying an older or equal version never regresses state.
§Queries
find_by uses Postgres’ data ->> $field
text-extraction operator. IS NOT DISTINCT FROM gives null-safe equality.
§Identifiers
sqlx binds values, not identifiers. Table names are spliced into SQL, so
they are validated against [A-Za-z0-9_] first ([check_ident]). Field
names are bound as the ->> operand and so are parameterized, but are still
validated for parity with the SQLite store.
Structs§
- Postgres
Read Model Store - Postgres implementation of
ReadModelStore.