How to get name of original stream from projection's event object?

Anywhere I can read about the various properties and structures in the “e” object (i.e. the event) for a projection.

I’m trying to do something like the below sample: create a “header” stream for each Widget stream. Widget streams are full of tons of low-level events, but when I want to just build up quick header information, I only care about a small subset of those events, so I want to create a companion “header” stream.

But how do I get the name of the original stream ( so I can extract the Widget ID from it? )

fromCategory(“Widget”)

.foreachStream()

.when({

WidgetCreated: function(s,e) {
var origStream = e.??? // HOW DO I GET THIS?
var widgetId = origStream.substring(7); // i.e. Widget-59e9a5f8-ac1b-41d9-8230-728a6be937e9
linkTo(“Table.header-” + widgetId, e);
},

WidgetAltered: function(s,e) { … /* ditto */ … },

WidgetDeleted: function(s,e) { … /* ditto */ … }

});

``

Just as a helper, you know you can debug projections in chrome and see
all this information in the debugger? Old UI but works very similarly
now https://www.youtube.com/watch?v=NFnsFfOMMkI

I'll let pieter follow up I am not sure if the stream id is exposed
there, that said in this case shouldn't Id be part of the event
itself?

Based on the screenshot from that YouTube it appears “streamId” is the property I was looking for.

But no, I hadn’t tried debugging in Chrome. Good to know…

It should still be in the event in this case. WidgetCreated but no Id
in the event? You can hack through it in a projection but what about
another consumer? Also if you use a linkTo on it it can appear in a
different stream (say foobarbaz) where you wouldn't be able to parse
the stream name to get the id.

The streams in the “Widget” category should all be originating streams, not projection streams with linked events.

Sure, in WidgetCreated, I can grab the id from there, but the other events I can only extract the widget UUID from the stream name, so hence “streamId”.

"Sure, in WidgetCreated, I can grab the id from there, but the other
events I can only extract the widget UUID from the stream name, so
hence "streamId". "

Normally you would want widget id in the event not just the streamid
if for no other reason than you dont want every consumer to have to
parse a stream name

Fair enough. Thanks.

Hi Zach, apologies for only getting back to you now.
If you want to know what properties are on the event for the handler, you can find them here. https://github.com/EventStore/EventStore/blob/release-v4.0.0/src/EventStore.Projections.Core/Prelude/Projections.js#L267