Class: EventStoreClient::GRPC::Commands::Projections::Update

Inherits:
Command
  • Object
show all
Defined in:
lib/event_store_client/adapters/grpc/commands/projections/update.rb

Instance Method Summary collapse

Methods inherited from Command

inherited, #metadata

Methods included from Configuration

#config

Instance Method Details

#call(name, streams) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/event_store_client/adapters/grpc/commands/projections/update.rb', line 17

def call(name, streams)
  data = <<~STRING
    fromStreams(#{streams})
    .when({
      $any: function(s,e) {
        linkTo("#{name}", e)
      }
    })
  STRING

  options =
    {
      query: data,
      name: name,
      emit_enabled: true
    }

  service.update(request.new(options: options), metadata: )

  Success()
rescue ::GRPC::AlreadyExists
  Failure(:conflict)
end