Can category name in fromCategory() be passed as a parameter?

I’m very new to the Event Store (and JavaScript), but seem to have encountered a question I don’t see covered anywhere else.

Question**: Is it possible to create a single projection that could be invoked with different values for the category name in the fromCategory(’CATEGORY NAME’) statement?**

Additional background: I’m building a POC to track the real-time holdings of securities in accounts for a firm that trades equities. A holding is uniquely identified by an AccountId (~300 accounts), a SecurityId (2000-3000 equities), and a HoldingType (i.e. long or short). I’m currently creating a stream for each position. I need to show that I can generate a report from the streams that contains the current holdings for each position (i.e. a table with columns, AccountId, SecurityId, HoldingType, ShareQuantity). I’m simplifying the problem a bit, but this should be enough detail for the purposes of this question.

I currently have a projection that looks something like this:




    $init: function()

return {





function(state, event)


state.totalIntradayHoldings += event.body.HoldingUpdateState.Quantity;


By changing the partition in the URL which invokes the projection, I can get the number of shares owned within each position on ACCOUNT1:

curl -i

I’m planning to write some C# code to generate all the partition strings and makes the many HTTP calls to the projection(s). (i.e. ACCOUNT1-5723777short, ACCOUNT1-5724099long, ACCOUNT1-5724099short, etc…). I’ll get a list of all the security ids each account trades and whether the account has long and/or short positions for those securities. There’s an example of this C# code creating the partition string and invoking the projection in Chapter 26 (see listings 26-14 and 26-15) of Patterns, Principles, and Practices of Domain-Driven Design (WROX Press). Back to my original question: I’d like to create a single projection and pass in the name of the account. Otherwise, I think I’ll need to create 300 projections that are the same, except for the name of the account in the statement fromCategory(‘ACCOUNT1’).


David Madrian

It seems to me like a modelling-problem. The category here (to me) looks like “account”. Why not just name the streams “ACCOUNT*-1-5724099long*” and use fromCategory(‘ACCOUNT’)?


Don’t know how I overlooked this option, but this is getting me what I need. Thanks!