"Dynamic" cross stream projections

While I’m experienced with event stores, I’m new to Event Store and its projections feature. Excuse me if I use the incorrect terms or ask an obvious question.

I am really interested in projections that cross multiple streams. I’ve read the two blog posts and their supporting entries:



My question is, what can I do or what options do I have if I don’t know the Stream IDs upfront? My specific use case is banking related. Lets say I have a stream per account and a customer can have multiple accounts. How can I write a projection that will run for each customer and process events across all their accounts?

The declaration of a projection seems to rely on knowing the stream IDs upfront. For “n” number of customers with each of those customers having “n” number of accounts, I won’t know the stream IDs at design time.



The way to handle this is to layer projections....

First do one that runs for all accounts and reindexes->customer then
write the projection per customer (eg forEach)

Another way of doing this is to use a custom state function