A ProjectionStore kept in a SQLite file. ProjectionEngine.make creates one for each projection; with ProjectionEngine.makeWithStores you create them yourself.
The rows are kept in a table named after A, with one column for each field, in snake_case, and a unique index on the ID column. The watermark and the schema hash are kept in a table called _projection_meta, in a row named after the rows' table. The tables are created the first time the store is used, not when it is made.
upsert uses INSERT ... ON CONFLICT DO UPDATE, and falls back to INSERT OR REPLACE if SQLite rejects that statement. updateFields checks every field name against the table's columns before it starts, then runs INSERT OR IGNORE for the default row and one UPDATE for each field update, in one transaction.
The constructor is private: create a store with SQLiteProjectionStore.make.
Type parameters
- A
-
the type of a row, with an EntityPath that names its ID field
Attributes
- Companion
- object
- Source
- SQLiteProjectionStore.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Adds the column columnName, if the rows do not have it yet. The migration shortcut calls it for each field that a migration adds.
Adds the column columnName, if the rows do not have it yet. The migration shortcut calls it for each field that a migration adds.
The default does nothing. SQLiteProjectionStore checks the name against ^[a-zA-Z_][a-zA-Z0-9_]*$ and runs ALTER TABLE ... ADD COLUMN.
Value parameters
- columnName
-
the name of the column, in snake_case
- sqlType
-
the SQL type of the column, such as
TEXT
Attributes
- Definition Classes
- Source
- SQLiteProjectionStore.scala
Removes the row with the ID entityId, if there is one.
Removes the row with the ID entityId, if there is one.
Value parameters
- entityId
-
the ID of the row to remove
Attributes
- Source
- SQLiteProjectionStore.scala
Reads the row with the ID entityId.
Reads the row with the ID entityId.
Value parameters
- entityId
-
the ID of the row to read
Attributes
- Returns
-
the row, or
Noneif there is none - Source
- SQLiteProjectionStore.scala
The watermark: the sequence number of the last event applied to the rows, or 0 if none has been applied yet. The engine reads it at startup, to continue after that event.
The watermark: the sequence number of the last event applied to the rows, or 0 if none has been applied yet. The engine reads it at startup, to continue after that event.
Attributes
- Source
- SQLiteProjectionStore.scala
The schema hash saved with the rows, or None if none has been saved yet, as in a new store.
The schema hash saved with the rows, or None if none has been saved yet, as in a new store.
Attributes
- Source
- SQLiteProjectionStore.scala
Adds a as a new row, under the ID read from its ID field.
Adds a as a new row, under the ID read from its ID field.
Fails if a row with that ID already exists.
Value parameters
- a
-
the row to add
Attributes
- Source
- SQLiteProjectionStore.scala
Starts the rows over for a new shape of A. A full rebuild calls it before it replays the events.
Starts the rows over for a new shape of A. A full rebuild calls it before it replays the events.
The default only removes the rows with truncate. SQLiteProjectionStore drops the table and creates it again for the current shape of A.
Attributes
- Definition Classes
- Source
- SQLiteProjectionStore.scala
Removes every row. The watermark and the schema hash are kept.
Removes every row. The watermark and the schema hash are kept.
Attributes
- Source
- SQLiteProjectionStore.scala
Applies updates to the row with the ID entityId, as one change.
Applies updates to the row with the ID entityId, as one change.
If there is no such row yet, it is first created with a default value in each column, so that, for example, the first increment of a counter gives 1. The updates are applied in order.
Value parameters
- entityId
-
the ID of the row to change
- updates
-
the changes to apply; their field names are column names, in snake_case, such as
user_count. An empty chunk does nothing.
Attributes
- Source
- SQLiteProjectionStore.scala
Saves seq as the watermark. The engine calls it after it applies an event.
Saves seq as the watermark. The engine calls it after it applies an event.
Value parameters
- seq
-
the sequence number of the last event applied to the rows
Attributes
- Source
- SQLiteProjectionStore.scala
Saves hash as the schema hash of the rows. The engine calls it once the rows match the current shape of A.
Saves hash as the schema hash of the rows. The engine calls it once the rows match the current shape of A.
Value parameters
- hash
-
the fingerprint of the shape of
A, from SchemaHash
Attributes
- Source
- SQLiteProjectionStore.scala
Adds a as a new row, or replaces the row that has the same ID.
Adds a as a new row, or replaces the row that has the same ID.
Value parameters
- a
-
the row to add or replace
Attributes
- Source
- SQLiteProjectionStore.scala