{"id":13776640,"url":"https://github.com/nerdyworm/es","last_synced_at":"2025-05-11T10:31:11.175Z","repository":{"id":137835592,"uuid":"88568459","full_name":"nerdyworm/es","owner":"nerdyworm","description":"Event Stores and Streams for elixir","archived":false,"fork":false,"pushed_at":"2017-12-15T02:29:18.000Z","size":43,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-02-13T09:10:40.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerdyworm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-18T01:41:34.000Z","updated_at":"2024-08-03T18:10:29.867Z","dependencies_parsed_at":"2023-04-17T05:29:28.338Z","dependency_job_id":null,"html_url":"https://github.com/nerdyworm/es","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyworm%2Fes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyworm%2Fes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyworm%2Fes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyworm%2Fes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerdyworm","download_url":"https://codeload.github.com/nerdyworm/es/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253551650,"owners_count":21926329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:30.906Z","updated_at":"2025-05-11T10:31:10.718Z","avatar_url":"https://github.com/nerdyworm.png","language":"Elixir","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# ES\n\nEvent Sourcing for Ecto and Postgresl/Dynamodb events storage.\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `es` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:es, \"~\u003e 0.1.0\"}]\nend\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/es](https://hexdocs.pm/es).\n\n## Configuration\n\n### Aggregates\n\n```elixir\ndefmodule Person do\n  use ES.Aggregate\n  use Ecto.Schema\n  import Ecto.Changeset\n\n  embedded_schema do\n    field :name, :string\n    field :version, :integer, default: 0\n    field :pending, {:array, :string}, default: [], virtual: true\n    field :changesets, {:array, :string}, default: [], virtual: true\n  end\n\n  defmodule Created do\n    use Ecto.Schema\n\n    @primary_key false\n    embedded_schema do\n      field :name, :string\n      field :uuid, :string\n    end\n\n    def changeset(struct, params \\\\ %{}) do\n      struct\n      |\u003e Ecto.Changeset.cast(params, [:name, :uuid])\n      |\u003e Ecto.Changeset.validate_required([:name, :uuid])\n    end\n  end\n\n  def create(uuid, name) do\n    %Person{}\n    |\u003e apply(%Created{name: name, uuid: uuid})\n  end\n\n  def handle_event(%Created{name: name, uuid: uuid}, workflow) do\n    workflow\n    |\u003e change(%{name: name, id: uuid})\n  end\nend\n\ndefmodule EventStore do\n  use ES.EventStore, adapter: ES.Storage.Memory, inline: true\nend\n\n{:ok, pid} = EventStore.start_link\n\n{:ok, aggregate} = Person.create(ES.uuid, \"bob\")\n{:ok, aggregate} = EventStore.commit(aggregate)\n{aggregate.name, aggregate.version}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdyworm%2Fes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerdyworm%2Fes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdyworm%2Fes/lists"}