Skip to main content

Module read_model_store

Module read_model_store 

Source
Expand description

§Read Model Store

Backend-agnostic persistence layer for projection read models.

The ReadModelStore trait abstracts over storage backends (SQLite, Postgres, dqlite, in-memory) using a typed operation surface. Earlier iterations exposed execute(sql, params) and query(sql, params), which leaked the SQL dialect of whichever backend was wired in — projectors written against the SQLite store would silently bind to SQLite syntax. The current trait describes intent (upsert this row keyed by id, find rows where field=value) and lets each backend translate to its own dialect.

§Operations

  • upsert — version-gated insert-or-replace by primary key. The gate (existing.version < incoming.version) makes projectors idempotent under duplicate or out-of-order delivery.
  • delete — remove a row by primary key.
  • get — fetch one row by primary key.
  • find_by — fetch rows where a single field equals a value (covers email lookups, secondary index reads).
  • list — fetch all rows in a table.
  • truncate — wipe a table during projection rebuild.

§Implementations

  • InMemoryReadModelStore — built-in, for testing and ephemeral state.
  • SqliteReadModelStore (in arc-es-sqlite) — production SQLite.
  • Postgres / dqlite backends — planned.

Structs§

InMemoryReadModelStore
In-memory read model store for testing.
Upsert
Version-gated upsert command.

Enums§

ReadModelError
Errors from read model store operations.

Traits§

ReadModelStore
Backend-agnostic storage for projection read models.

Type Aliases§

ReadModelResult
Result type for read model store operations.
Row
A row stored or returned by a read model query, represented as a JSON object.