Getting started
The package can be installed from hex as follows.
Add
commanded_eventstore_adapter
to your list of dependencies inmix.exs
:def deps do [{:commanded_eventstore_adapter, "~> 1.0.0"}] end
Then run
mix deps.get
Create an event store for your application:
defmodule MyApp.EventStore do use EventStore, otp_app: :my_app end
Define and configure your Commanded application to use the
Commanded.EventStore.Adapters.EventStore
adapter 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 ] end
Configure the event store in each environment's mix config file (e.g.
config/dev.exs
), specifying usage of Commanded's JSON serializer:config :my_app, MyApp.EventStore, serializer: Commanded.Serialization.JsonSerializer, username: "postgres", password: "postgres", database: "eventstore_dev", hostname: "localhost", pool_size: 10
Add your event store to
config/config.exs
to make it easier to use the event store mix tasks:# config/config.exs config :my_app, event_stores: [MyApp.EventStore]
Create the
eventstore
database and tables using themix
task:$ mix do event_store.create, event_store.init