Purpose of the $stream_by_category system projection ?

I’m trying to understand the purpose of $stream_by_category
If I read the docs correctly & from some try outs

it produces new streams $category-[category] containing linked events to the *only the first event of each streams *in a given category ?

compared to $by_category that produces new streams $ce-[category] that links to *all events of each streams *in the given category.

So anynone uses *$stream_by_category *and what for ?

Thanks

Yves

I actually had a use for this. When restarting a job, I needed to look at the last event in each of the streams for a category. $ce-[category] wouldn’t work since that’s all events from all streams. But, by running through the events in $category-[category] I can quickly get all the streams for a category and then easily look at the last event in each of those.

Hope that makes sense.

Titus

Could you explain the difference again?
I’m staring at the docs and I can’t, for the life of me, see any difference between “stream_by_category” and “by_category” projections…

They seem to be identical… Both project events from a category. So if I have car-1, car-2, etc… both will project events into “$ce-car” or “$category-car” streams. Which would be the same?

Or am I missing something?

$stream_by_category actually just creates references of all created streams in category (as far as I’ve observed). So given your example:

$category-car stream would contain following events (even when there is more than one event per each car-* stream, those are only emitted when new stream in category is created):
1: {eventType: “$@”, data: “car-2”, metadata: { … $c: 1, $p: 1… }}
0: {eventType: “$@”, data: “car-1”, metadata: { … $c: 0, $p: 0 }}

Reference to the first event in stream are those $c and $p values, which are commit/prepare positions of first event in each stream. Data contains the actual stream name.

Dne nedelja, 08. april 2018 00.11.05 UTC+2 je oseba Andriy Drozdyuk napisala:

I also spend some time getting the streamnames from this projection as can be seen from https://groups.google.com/d/topic/event-store/W-7wMgpfUeQ/discussion .

Two thing i remember from this
1. There is something called a streamreference that is used. And that is different then the LinkTo events that are used in other projections
2. If you want to see the data/reference when you read an event with a http call you have to add ?embed=tryharder to the request.