Checking stream existence and listing all streams

Hi,

Are there plans to add an API to allow us to check whether a stream exists (I’ve already got some code to do this, so if a PR is wanted I can do that).

Also would it be possible to have API’s to list all streams and allow the user to query for streams that fit certain naming criteria. For example I have streams in the form {0}ReferenceList where 0 is currency. What I’d like to do is say
give me all streams that are reference lists, i.e that would translate in to a query that says for example give me all streams who’s names end with the string “ReferenceList”.

Any help appreciated.

Kind regards

Sean.

The second part yes there are plans for that (internal hosting of lucene)

For the first bit (check if stream exists) you can already do this. Readstreambackwards int.maxvalue, 1) this also gives you the current end of the stream :slight_smile:

Cheers,

Greg

Hi,

Is there any sample to list all streams currently? I’m assuming Lucene is not implemented as yet?

Kind regards

Sean.

Not pushed. There is not “give me all streams query” that said take a look at the $streams internal projection or you can listen on events and create a projection that creates this data for you from the outside.

Hi Greg,

Where in the source tree is the %streams projection created/is the source code of this projection?

Also, can I subscribe to projections, or do I need to keep querying them manually, any example(s) would be useful!

Kind regards

Sean.

Projections emit to streams. Streams you know for the rest of questions. Here you go (emits the 0th event in a stream to a stream called $streams. Listen to it and know all streams.

https://github.com/EventStore/EventStore/blob/dev/src/EventStore.Projections.Core/Standard/IndexStreams.cs

About list all streams:

Just played with Event Store 3.01 projection. Following js will return list of streams:

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++;
}
}
})

It is bad, need to iterate all of events.

This is a really bad idea. The state can be massive

Any good option?

$streams? https://github.com/EventStore/EventStore/blob/dev/src/EventStore.Projections.Core/Standard/IndexStreams.cs is the internal projection code. It must be enabled.

What will happe to your projection with 100m streams?