An event that has been persisted to an event store.
Returned by Sourced.EventStore.Behaviour.append/3 and
Sourced.EventStore.Behaviour.query/2, carrying the store-assigned
sequence alongside the fields the event was appended with.
The field types below are shared with the event maps handed to
Sourced.EventStore.Behaviour.append/3; see
Sourced.EventStore.Behaviour.event/0 for that shape.
Summary
Types
The event payload: a plain map, or a domain event struct when the store is
configured with a Sourced.Middleware.Domain.
Free-form metadata attached to an event. Keys are strings so the map round-trips cleanly through JSON-backed stores.
A reference to a domain concept the event concerns, conventionally written as
"prefix:id" — "order:123", "customer:42". Where type says what
happened, tags say what it happened to, and Sourced.EventStore.Query queries
them directly instead of reaching into the payload.
Types
The event payload: a plain map, or a domain event struct when the store is
configured with a Sourced.Middleware.Domain.
Free-form metadata attached to an event. Keys are strings so the map round-trips cleanly through JSON-backed stores.
@type t() :: %Sourced.StoredEvent{ data: data(), metadata: metadata(), occurred_at: DateTime.t(), sequence: non_neg_integer(), tags: [tag()], type: String.t() | module() }
@type tag() :: String.t()
A reference to a domain concept the event concerns, conventionally written as
"prefix:id" — "order:123", "customer:42". Where type says what
happened, tags say what it happened to, and Sourced.EventStore.Query queries
them directly instead of reaching into the payload.
Tags must be derivable from the event itself. Avoid personal data in them; hash or anonymise values such as usernames and emails.