I think I made the mistake of dumbing down the domain problem (and changing to a different domain in the process) to get a technical answer.
I will try to rephrase my question and use the real domain and the technical issues I have with it:
The application is a tracker of your bank statements. A user can add accounts (event: AccountCreated) and import or manually add his statements (event: StatementAdded). Then, based on a set of rules, the statements will be put into categories on which you can then run reports. These rules can run either only on import or could be run retroactively on already imported statements.
So, for example, there is a rule which states "if the description of the statement contains “supermarket” then put it in the category “food” ". These rules are dynamic and can be created by the user.
Now here’s the issue: when a user wants to remove a category, I need to make sure that the statements that are currently in that category either fall back to a default category (that can never be removed), fall back to a specific category or just have no category assigned (based on user input when the category is removed).
I have tried some of the things Yves suggested in his last message, namely creating a new stream that contains all the StatementAdded events. However, I’m not even able to create a simple projection that has all events from the account-category. (To clarify: Account is an aggregate which has a stream of AccountCreated and StatementAdded events. Every aggregate has its own stream Account- ). I have tried creating this simple projection:
but when I look at the resulting there are no events, even though there’s an account-stream which has a few events in it.
I have also followed the following tutorial: https://geteventstore.com/blog/20130213/projections-2-a-simple-sep-projection/ , just trying to create an event stream projection of the stats, but it doesn’t seem to work either. I have simply copy-pasted the code from the tutorial, when I click “Start”, it tells me it started, but the UI still tells me “StatsProjection - Stopped (Enabled)” (I made sure to select “continuous” in the creation screen).
I’m a bit at loss on how these projections work. I understand the idea behind it (at least I think I do), but I just can’t find a way to make them work. The console logs are not displaying any errors either.
@Yves: Apart from the technical issue I’m having, I was also wondering about the reason why you would create a new projection which contains all RoomAdded events, then subscribing to it and then writing the SQL. Wouldn’t it be easier to create an event listener to the original event in the first place without going through the projection? I’m not sure I see the benefit of the round trip (at least not when executing everything in a single process).
I know this is a bit of an extensive question and it’s mixing domain modeling questions with pure technical issues. For now, I’d be happy with just a solution of the technical problems I’m having so I can at least play around a bit with the domain modeling. (Although any advise on that is welcome as well :-))