Hi all, I’m hoping this has a quick answer that I’m just missing.
I have to admit in advance that I am quite new to Event Store, and a a recent graduate, quite new at many of development topics as well, so I hope this doesn’t seem to idiotic…
I have an issue where we’ve been pushing different types of events into a single stream and need to get a another stream of events with a unique EventId to them.
The case looks like, an event of type ‘Alert’ is stored to the stream with a unique guid, then later on, an event with type ‘ResolvedAlert’ and the same guid is stored to the stream. Up until now, we had simply used a projection to get a state count on the number of unresolved alerts. Now I’ve been asked to display all those unresolved ‘alerts’ and for the life of me I can’t get a projection working to do so.
I’ve tried the following in many forms, but I always seem to run into a race condition of sorts (what order are the events pulled in from the stream?), or some other issue that I can’t identify.
I know I can do this from within the application itself, but it would seem to me this would be better done from inside the Event Store instead (separation of data and what not).
fromStream(‘DVS.TeamDashboard’)
.when({
$init : function(){
return{ resolvedAlerts{} };
},
ResolvedAlert : function(state, event){
state.resolvedAlerts[event.body.EventId] = 1;
},
Alert : function(state, event){
if(state.resolvedAlerts[event.body.EventId] !== 1){
linkTo(“Unresolved Alerts”, event);
}
}
});
I appreciate any help in advance!
Thank you!