Sha256: d744661a16263fe0528a224891976cafc6b8f0494027e379cce9252c24f232a9

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module <%= project_class_name %>
  module Projections
    module <%= query_class_name %>
      class Projector
        include EventSourcery::Postgres::Projector

        projector_name :<%= query_name %>

        table :query_<%= query_name %> do
          # Add your projection table columns here, eg:
          # column :todo_id, 'UUID NOT NULL'
          # column :title, :text
          # column :due_date, DateTime
        end
    <%- if event_names.empty? -%>

        # project TodoAdded do |event|
        #   Modify your projection table here, eg:
        #   table.insert(
        #     todo_id: event.aggregate_id,
        #     title: event.body['title'],
        #     due_date: event.body['due_date'],
        #   )
        # end
    <%- else -%>
      <% event_names.each do |event_name| %>
        project <%= event_name.underscore.camelize %> do |event|
          #   Modify your projection table here, eg:
          #   table.insert(
          #     todo_id: event.aggregate_id,
          #     title: event.body['title'],
          #     due_date: event.body['due_date'],
          #   )
        end
      <%- end -%>
    <%- end -%>
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
event_sourcery_generators-0.2.0 lib/event_sourcery_generators/generators/templates/query/projector.rb.tt