Class: EventStoreClient::HTTP::Commands::Projections::Create

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

Instance Method Summary collapse

Methods inherited from Command

inherited

Instance Method Details

#call(name, streams, options: {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/event_store_client/adapters/http/commands/projections/create.rb', line 8

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

  connection.call(
    :post,
    "/projections/continuous?name=#{name}&type=js&enabled=yes&emit=true&trackemittedstreams=true", # rubocop:disable Metrics/LineLength
    body: data,
    headers: {}
  )
end