⌚ OpenOpeningstijden main server application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nodes.rb 988B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # frozen_string_literal: true
  2. module Hours
  3. module Projections
  4. module Nodes
  5. ##
  6. # Handles the Nodes Projection
  7. class Projector
  8. include EventSourcery::Postgres::Projector
  9. projector_name :nodes
  10. # Database tables that form the projection.
  11. table :query_nodes do
  12. column :node_id, 'UUID NOT NULL'
  13. column :name, :text
  14. column :opening_hours, :text
  15. column :location, 'geography(POINT)'
  16. end
  17. # Event handlers that update the projection in response to different
  18. # events from the store.
  19. project NodeAdded do |event|
  20. table.insert(
  21. node_id: event.aggregate_id,
  22. name: event.body['name'],
  23. opening_hours: event.body['opening_hours'],
  24. location: GeoRuby::SimpleFeatures::Point.from_x_y(
  25. event.body['lon'],
  26. event.body['lat']
  27. )
  28. )
  29. end
  30. end
  31. end
  32. end
  33. end