commanded/commanded-ecto-projections

Document the usage of `multi`.

suzdalnitski opened this issue · 2 comments

It's not immediately clear what the multi passed to the projection function actually does:

project (%MyEvent{}, _, fn multi -> ... end)

How does using this multi differ from returning a new Ecto.Multi?

project (%MyEvent{}, _, fn -> Ecto.Multi.new() ... end)

Does the multi passed to the projection function already contain some other operations? Does it group some other operations together with the projection?

Thanks!

Does the multi passed to the projection function already contain some other operations?

Yes

|> Ecto.Multi.run(:verify_projection_version, fn repo, _changes ->

|> Ecto.Multi.update(:projection_version, changeset, prefix: prefix)

Does it group some other operations together with the projection?

Yes

|> Ecto.Multi.run(:verify_projection_version, fn repo, _changes ->

|> Ecto.Multi.update(:projection_version, changeset, prefix: prefix)

How does using this multi differ from returning a new Ecto.Multi?

No differences. That multi is an Ecto.Multi

@suzdalnitski do you mind creating a PR tackling your concern?