Count all events


is there a simple way to count all stored events in all the stream. We need this for our Metadata.

– Ivo

There is not now and its basically impossible to support if partitioned. What sre you trying to accomplish

We want to be able to read all events from a given global event number. So if some events were lost on the way, or the Readmodels were offline, they can just get all the events from global version x to global version y from the ES.

You can make a persistent projection which links to all events. This will shortly be built into the product directly.

For the projection, use something like:


function(state, event) {

    linkTo('temp-all-stream', event);




When this is running, a stream will be present on http://:2113/streams/temp-all-stream in the normal manner, and you can read it using the TCP interface in the normal manner if that’s what you’re using.

Again note that this is a temporary requirement - a built-in stream named $all is being built at the moment.



Thanks James!

Just started working on projections, and have a question. Will this count in this projection:

$init: function () {
return { count: 0 }; // initial state
$any: function (s, e) {
s.count += 1;
return s;


be incremented on idempotent write of event? Can I filter out such writes in projection?


It should not be incremented on an idempotent write by definition of an idempotent write