Merge Two Streams?

Hi,

I am slowly but surely learning things about the EventStore as I need them. My newest scenario is that I have multiple streams and I would like to merge them together and then make a projection off of the new stream.

I have one set of streams: User-{id} and another stream: Sessions where some of the events generated in the Sessions stream will have a UserId that matches the {id} in the User aggregate stream. I want to merge them together into a set of UserSession-{id} streams and then run a foreachStream projection off of the new stream.

Is this possible?

I think you could do this with 2 projections, one which reads all events and creates a stream at UserSession-{id} using linkTo

You can then have your foreachStream looking at those streams generated by the first projection?

Fromstreams(s1,s2){}

Thanks, Rich. I have had some issues viewing linkTo streams, but that seems like the way to go.

Greg, I wouldn’t be able to use fromStreams with a “parameterized” stream names (User-{id}) would I?

Brian,

this is what fromCategory() is intended for.

if you enable “categorize events by path” predefined projections all the events written to user-{id} streams are indexed into system stream $ce-user.

then you can write you query as

fromCategory(‘usr’).when(…

or if you need partitioned projection by original streams:

fromCategory(‘user’).foreachStream().when({…

The “categorize events by path” is implemented in C# only for efficiency reasons, but what is does is

  1. take a stream name and extract a stream category from its name (user-{1} => user). the separator is configurable

  2. linkTo(category, originalEvent);

-yuriy

Awesome, Yuriy! Thanks. :slight_smile:

not now. Is there a specific type of event or all events from the two
streams should go to a new stream?