A zio.blocks.projection.ProjectionStore kept in memory, for tests. TestEngine creates one for each projection.
The rows are kept in a map from entity ID to row, and the watermark and the schema hash in two Refs. Nothing is written to disk, so everything is lost when the program ends.
insert fails if the ID is already taken. updateFields changes the row as a DynamicValue. When there is no row yet, it starts from a default one, in which the ID field holds entityId and the other fields hold empty values, such as None, 0, "" or false. It accepts a field either by its column name, in snake_case, or by its Scala name. recreateTable only removes the rows, and addColumn does nothing, because a map has no columns.
The constructor is private: create a store with InMemoryProjectionStore.make.
Type parameters
- A
-
the type of a row, with an zio.blocks.projection.EntityPath that names its ID field
Attributes
- Companion
- object
- Source
- InMemoryProjectionStore.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
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
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
- InMemoryProjectionStore.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
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
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
Removes every row. The watermark and the schema hash are kept.
Removes every row. The watermark and the schema hash are kept.
Attributes
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
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
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
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
Inherited 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
- Inherited from:
- ProjectionStore
- Source
- ProjectionStore.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
- Inherited from:
- ProjectionStore
- Source
- ProjectionStore.scala