Scavenging / $maxAge and projections

We have a system that produces events we write to eventstore, basically a stream for each “user”. We use projections to sort those events into different streams for accessing them in a sane way, as suggested in The cost of creating a stream.

Now we would like to use scavenging (events older than a month are of no interest to us) to save storage. For that we would have to set $maxAge in the stream metadata. Now to the question: Is ist enough to set $maxAge on the stream we write the events to, and when they are ready to be deleted with scavenging, they will also be deleted from the streams we created with the projections? Or would we have to set $maxAge on every stream the event is put in through projections as well for the events to be deleted?

If so, is it possible to set stream metadata in a simple way directly in the projection definition code (couldn’t find an example for that)? Or is ist somehow possible to set a default $maxAge for all streams created in the future?

Thanks for your support.

It depends on your projection and whether you use emit or linkTo. With
linkto they will get scavenged by setting the maxAge on the original
stream. With emit you would need to set it on the stream you are
emitting to

Thanks, it’s linkTo. It would still be great to have the possibility to set a default maxAge/maxCount for all new streams. Especially useful when streams are automatically created while writing Events to new streams.

No its per stream.


How would you set maxAge on new streams created with ‘emit’ function?