Getting started
The package can be installed from hex as follows.
Add
commanded_eventstore_adapterto your list of dependencies inmix.exs:def deps do [{:commanded_eventstore_adapter, "~> 1.4"}] endThen run
mix deps.getCreate an event store for your application:
defmodule MyApp.EventStore do use EventStore, otp_app: :my_app endDefine and configure your Commanded application to use the
Commanded.EventStore.Adapters.EventStoreadapter and your own event store module:defmodule MyApp.Application do use Commanded.Application, otp_app: :my_app, event_store: [ adapter: Commanded.EventStore.Adapters.EventStore, event_store: MyApp.EventStore ] endConfigure the event store in each environment's mix config file (e.g.
config/dev.exs), specifying usage of Commanded's JSON serializer:import Config config :my_app, MyApp.EventStore, serializer: Commanded.Serialization.JsonSerializer, username: "postgres", password: "postgres", database: "eventstore_dev", hostname: "localhost", pool_size: 10Add your event store to
config/config.exsto make it easier to use the EventStore mix tasks:# config/config.exs import Config config :my_app, event_stores: [MyApp.EventStore] import_config "#{config_env()}.exs"Create the EventStore database and tables using the
mixtask:mix do event_store.create, event_store.init