Cqrs.DomainEvent (cqrs_tools v0.5.28) View Source
Defines a new domain event struct
Options
:fromoptional - a struct to derive fields from.:withoptional - a list ofatomfield names to add.:dropoptional - a list ofatomfield names to remove from any field derived from the struct in the:fromoption.:versionoptional - a version value. Defaults to1
Example
defmodule DeleteUser do
use Cqrs.Command
field :id, :integer
def handle_dispatch(command, _opts) do
{:ok, :no_impl}
end
end
defmodule UserDeleted do
use Cqrs.DomainEvent,
from: DeleteUser,
with: [:from],
version: 2
end
iex> cmd = DeleteUser.new!(id: 668)
...> event = UserDeleted.new(cmd, from: "chris")
...> %{id: event.id, from: event.from, version: event.version}
%{id: 668, from: "chris", version: 2}