Getting the original stream from events projected by $stream_by_category

120 views
Skip to first unread message

Arno den Uijl

unread,
May 22, 2018, 5:58:28 AM5/22/18
to Event Store
Hi,

I've found some posts regarding the $stream_by_category projection but I haven't been able to answer my question with these.

I have a bunch of streams in a category name connection. Now I want to get all the streams in that category. If I understand correct the $stream_by_category projection should create a stream named $category-connection that links all the first events in all the connection-* streams.

If I look in the $category-connection stream i see entries, but I have no idea how to get to the original source stream.

If I use the .Net client I both OriginalStreamId and Event.EventStreamId are "$category-connection" and I see no reference to the original connectoin-xxxx stream. Even if i set resolveLinkTos to true (I use ReadStreamEventsForwardAsync).

If i do a request on the HTTP api I see the following entries:
http://127.0.0.1:2113/streams/$category-connection
Accept:application/vnd.eventstore.atom+json
ES
-ResolveLinkTo:true


   
"entries": [
       
{
           
"title": "393221@$category-connection",
           
"id": "http://127.0.0.1:2113/streams/%24category-connection/393221",
           
"updated": "2018-05-22T08:04:59.738933Z",
           
"author": {
               
"name": "EventStore"
           
},
           
"summary": "$@",
           
"links": [
               
{
                   
"uri": "http://127.0.0.1:2113/streams/%24category-connection/393221",
                   
"relation": "edit"
               
},
               
{
                   
"uri": "http://127.0.0.1:2113/streams/%24category-connection/393221",
                   
"relation": "alternate"
               
}
           
]
       
}

How do I find a reference to the connection-xxxxx stream this?

kind regards,

Arno



Greg Young

unread,
May 22, 2018, 6:10:36 AM5/22/18
to event...@googlegroups.com
The payload of the link event is $>1234@streamname  if you look. I believe this is also surfaced in the API but don't remember off the top of my head where (I will look through the api in a bit).

--
You received this message because you are subscribed to the Google Groups "Event Store" group.
To unsubscribe from this group and stop receiving emails from it, send an email to event-store+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Studying for the Turing test

Arno den Uijl

unread,
May 22, 2018, 9:15:19 AM5/22/18
to Event Store
If I request a single event with embed=body I get the following. Hould it be in here?:

http://127.0.0.1:2113/streams/%24category-connection/9237?embed=body

{
   
"eventId": "42f7d4f8-f49f-4e8b-a901-af5a405f92ae",
   
"eventType": "$@",
   
"eventNumber": 9237,
   
"metaData": "{\"$v\":\"4:-1:1:3\",\"$c\":858258872,\"$p\":858258872,\"$causedBy\":\"0c480f70-acca-4af2-bd41-bdf4c3c5a7b2\"}",
   
"streamId": "$category-connection",
   
"isJson": false,
   
"isMetaData": true,
   
"isLinkMetaData": false,
   
"positionEventNumber": 9237,
   
"positionStreamId": "$category-connection",
   
"title": "9237@$category-connection",
   
"id": "http://127.0.0.1:2113/streams/%24category-connection/9237",
   
"updated": "2018-05-22T12:12:34.823235Z",

   
"author": {
       
"name": "EventStore"
   
},
   
"summary": "$@",
   
"links": [
       
{

           
"uri": "http://127.0.0.1:2113/streams/%24category-connection/9237",
           
"relation": "edit"
       
},
       
{
           
"uri": "http://127.0.0.1:2113/streams/%24category-connection/9237",
           
"relation": "alternate"
       
}
   
]
}

To unsubscribe from this group and stop receiving emails from it, send an email to event-store...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Arno den Uijl

unread,
May 26, 2018, 2:52:31 PM5/26/18
to Event Store
Thanks for the hint Greg. It indeed is in the payload (data).

I was able to get it out with:

Encoding.UTF8.GetString(e.Event.Data)

It's so simple once you know it. I was so used to events and links to events that I never realised there is something like a 'StreamReference' and that it is a bit different than a normal link event. I was just trying to get it out with 'e.OriginalStreamId' or 'e.Event.EventStreamId' and with resolveLinkTos to false and true.

Why isn't it 'just' a link event like in the '$ce-xxxx' streams? I think what would make it simpler. (i have just a basic understanding of how the eventstore works, so this might be weird thing to suggest.)

Reply all
Reply to author
Forward
0 new messages