Selecting multiple event streams for query (and projections) based on stream name prefix

Hello, fellow EventStorers!

We are storing each aggregate’s events in its own stream. For example, we have streams named user_0001, user_0002, user_0003 and so forth.

I would like to build a query in the Admin UI to process events for all the streams whose names start with (thus those that have a prefix of) “user_”.

According to the documentation, it is possible to select multiple streams by using the fromStreams() method. Using this method, I can successfully build a query (and projections) by using a selector like fromStreams(['user_0001', 'user_0002', 'user_0003']).

But naturally, we cannot know all possible stream names up-front.

What is the best approach to use to select all streams with a prefix of “user_” for an Admin UI query (or for a projection)?

Apologies if this is not the best category in which to post my question.

Hi,
if you use a stream name pattern of ‘[type]-[id]’ (note: hyphen rather than underscore) and turn on the standard projections event store will do this for you by creating link to streams of the format ‘$ce-[type]’
so the ‘$ce-user’ stream would have all events in order from all three user streams in your example.
-Chris

Thank you @chris.condron

For those seeking additional information, here is a link to the section of the documentation that deals with these and related system projections: https://developers.eventstore.com/server/v20/server/projections/system-projections.html#enabling-system-projections