ExESDB.StreamsHelper (ex_esdb v0.1.6)

Provides helper functions for working with event store streams.

Summary

Functions

calculate_versions(start_version, count, direction)

get_version!(store, stream_id)

@spec get_version!(
  store :: atom(),
  stream_id :: String.t()
) :: integer()

Returns the version of the stream using 0-based indexing. ## Parameters

  • store is the name of the store.
  • stream_id is the name of the stream.

## Returns

  • version (0-based) or -1 if the stream does not exist. This means:
  • New stream (no events): -1
  • Stream with 1 event: 0 (version of latest event)
  • Stream with 2 events: 1 (version of latest event)
  • etc.

pad_version(version, length)

stream_exists?(store, stream_id)

to_event_record(new_event, stream_id, version, created, created_epoch)

version_to_integer(padded_version)