patrick
patrick

Reputation: 16959

Projection that merges two streams in eventstore

I am trying to create the simplest projection using fromStreams, the code saves fine, but the stream mergeStream0 does not exist

var create = function () {
    fromStreams(['storeIdStream7', 'storeIdStream'])
         .when(function(state,event) { 
             emit('mergeStream0', 'mergeType', '123')
     return null; 
  });
};
create() 

Upvotes: 2

Views: 476

Answers (1)

Piotr Kula
Piotr Kula

Reputation: 9821

You need to make sure that run projections ALL has been called on your event store

When using the embedded client the options is as follows

var nodeBuilder = EmbeddedVNodeBuilder.AsSingleNode()
    .OnDefaultEndpoints()
    .RunInMemory()
    .RunProjections(EventStore.Common.Options.ProjectionType.All, 1);

When starting it on a server you need to include this in your eventstore.conf

RunProjections: All
ClusterSize: 1
ExtIp: 0.0.0.0

Also your projection will only display the links to the original streams, you can also use linkTo(state, event); to link to the actual data so it comes back within the projection. But if you omit that, you can use the client and set resolveLinkTos to true

Upvotes: 0

Related Questions