reckon_db_snapshots (reckon_db v1.2.7)
View SourceSnapshots API facade for reckon-db
Provides the public API for snapshot operations: - save: Save aggregate state as a snapshot - load: Load the latest snapshot for a stream - load_at: Load a specific snapshot version - list: List all snapshots for a stream - delete: Delete snapshots for a stream - exists: Check if a snapshot exists
Snapshots are used to optimize event replay by storing aggregate state at specific versions.
Summary
Functions
Delete all snapshots for a stream
Delete a specific snapshot version
Check if any snapshot exists for a stream
Check if a specific snapshot version exists
List all snapshots for a stream
Load the latest snapshot for a stream
Load a specific snapshot version
Save a snapshot with default empty metadata
Save a snapshot with metadata
Types
Functions
Delete all snapshots for a stream
-spec delete_at(atom(), binary(), non_neg_integer()) -> ok | {error, term()}.
Delete a specific snapshot version
Check if any snapshot exists for a stream
-spec exists_at(atom(), binary(), non_neg_integer()) -> boolean().
Check if a specific snapshot version exists
List all snapshots for a stream
Load the latest snapshot for a stream
Returns {ok, Snapshot} if found, {error, not_found} otherwise.
-spec load_at(atom(), binary(), non_neg_integer()) -> {ok, snapshot()} | {error, not_found}.
Load a specific snapshot version
-spec save(atom(), binary(), non_neg_integer(), snapshot_data()) -> ok | {error, term()}.
Save a snapshot with default empty metadata
Parameters: StoreId - The store identifier StreamId - The stream this snapshot belongs to Version - The event version this snapshot represents Data - The aggregate state to snapshot
Returns ok on success or {error, Reason} on failure.
-spec save(atom(), binary(), non_neg_integer(), snapshot_data(), snapshot_metadata()) -> ok | {error, term()}.
Save a snapshot with metadata