Skip to content

[Recipe] Link events from one stream to another #16

Description

@slashdotdash

How to link an existing event from one stream to another.

Use an event handler to link events of a given type into another stream.

The source event_id is accessible via metadata:

def handle(%ProductSold{} = event, metadata) do
  %ProductSold{user_id: user_id} = event

  event_id = Map.get(metadata, :event_id)

  MyApp.EventStore.link_to_stream(user_id, :any_version, [event_id])
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions