defmodule CustomerService.Projectors.Customer do use Commanded.Projections.Ecto, application: CustomerService.CommandedApp, repo: CustomerService.Repo, name: "CustomerService.Projetors.Customer", consistency: :strong alias CustomerService.Events alias CustomerService.Projections.Customer project(%Events.CustomerCreated{} = event, fn multi -> Ecto.Multi.insert(multi, :customer, %Customer{ id: event.id, first_name: event.first_name, last_name: event.last_name, birth_date: event.birth_date, gender: event.gender, email: event.email, phone: event.phone }) end) # project %Events.CustomerDeactivated{} = event, _metadata do # Ecto.Multi.update_all( # multi, # :deactivate_customer, # from(c in Customer, where: c.customer_id == ^event.customer_id), # set: [active: false] # ) # end end