Skip to content

Commit

Permalink
Merge pull request #5 from maxohq/feat/private-data-sample
Browse files Browse the repository at this point in the history
Chore: example how to update private data on projections
  • Loading branch information
mindreframer authored Dec 27, 2024
2 parents 3cf9f3c + 673edcd commit e4987ee
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/sample/projections/proj1.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
defmodule Sample.Projections.Proj1 do
@moduledoc """
```elixir
## reset projection
iex> Essig.Projections.Runner.reset(Sample.Projections.Proj1)
## fetch projection state
iex> Essig.Projections.Runner.get_state_data(Sample.Projections.Proj1)
```
"""
use Essig.Projections.Projection
alias Essig.Projections.Data
use Essig.Repo
Expand All @@ -13,6 +23,11 @@ defmodule Sample.Projections.Proj1 do
{:ok, 1}
end)

# update projection specific private data
private = data.private
private = Map.put(private, {:index, index}, true)
data = %Data{data | private: private}

{multi, data}
end

Expand Down

0 comments on commit e4987ee

Please sign in to comment.