Friday, February 20, 2015

How to get stream name list from Event Store?

Better idea from Greg Young

Greg Young gregoryyoung1@gmail.com 

Feb 20 (3 days ago)
to event-store 
What will happe  to your projection with 100m streams?




Original test code:

fromAll().
    when({
        $init: function(s,e) { return {streanList:"", count:0} },
        $any : function(s,e) {
            if (!s.streanList){
                s.streanList =" ";
            }
            if (s.streanList.indexOf(e.streamId) < 0){
               s.streanList = s.streanList + e.streamId +",";
               s.count++;
            }
        }
    })

Reference:
http://dbs-are-fn.com/2013/interview_greg_young_event_store/

How to count event number in one stream?

fromStream("streamName")
   .when({
        $init: function() {
           return { count: 0 }
        },
        $any : function(s,e) { return s + 1;}
  })

How to count event number in Event Store?

fromAll().
    when({
        $init: function(s,e) { return 0;},
        $any : function(s,e) { return s + 1;}
    })