View Source Getting started
You should already have Ecto installed and configured before proceeding. Please follow Ecto's Getting Started guide to get going first.
Add
:commanded_ecto_projections
to your list of dependencies inmix.exs
:def deps do [ {:commanded_ecto_projections, "~> 1.4"} ] end
Generate an Ecto migration in your app:
$ mix ecto.gen.migration create_projection_versions
Modify the generated migration, in
priv/repo/migrations
, to create theprojection_versions
table:defmodule CreateProjectionVersions do use Ecto.Migration def change do create table(:projection_versions, primary_key: false) do add(:projection_name, :text, primary_key: true) add(:last_seen_event_number, :bigint) timestamps(type: :naive_datetime_usec) end end end
Run the Ecto migration:
$ mix ecto.migrate
Define your first read model projector:
defmodule MyApp.ExampleProjector do use Commanded.Projections.Ecto, application: MyApp.Application, repo: MyApp.Projections.Repo, name: "example_projection" end
Refer to the Usage guide for more detail on how to configure and use a read model projector.