How to create a stream that discards old data?

I saw a mention somewhere that I can create a stream that keeps only, say, last 10 items.

Can anyone point me to the doc or code for that?

I’m trying to make my snapshot stream discard old events (I really only need last 1-events).

set $maxAge or $maxCount on stream metadata

How do you set this metadata?

I see an example here:

But it seems to be setting “event” metadata, and not a stream metadata:

        "eventId": "7c314750-05e1-439f-b2eb-f5b0e019be72",
        "eventType": "$user-updated",
        "data": {
            "readRole": "$all",
            "metaReadRole": "$all"

Sorry, but I’m still not understanding it.

What is the event id in metadata.txt in the example?

metadata is just another stream

if you have a stream foo the metadata is $$foo. http and the tcp
client abstract this from you with /streams/foo/metadata etc but this
is for convenience. If you look in stream browser this is more obvious


Ok, I had success, but I had to post NOT to metadata stream, but to the same stream that I wanted to set max count on.

E.g. if I want to limit maxCount on my snapshots stream, I had to do this:

curl -i “” -H “Content-Type:application/vnd.eventstore.e vents+json” -d '[



    "eventType" : “my_snapshot",

    "data" : {            

        "$maxCount" : 1,

         "memento" : {    

           "state": “working”,

           “progress_id": "9e3f0f32-df64-11e6-a0eb-080027d07966",

           “entity_type": “blah”,

           "opts": "undefined",

           "name": "Reddit",

           “entity_id": "Ball"


         "event_number": 25408





The part that stream’s metadata had to be part of the event data was not clear to me from the documentation.

At first I tried posting to the “” which just created a new metadata stream - and didn’t alter the maxCount of my “my_snapshots-Ball” stream.

Hopefully, this helps anyone trying to do this in the future.

Oh wait, I think posting to “/metadata” actually set the $maxCount and not to the regular stream…

I take my statement back.