According to which pattern do you change your projections?

In our system we have a projection for each bounded context in which its domain events are combined. Unfortunately we forgot to add another stream to the projection.

I see two ways to change the projection to process the forgotten events.

  1. I stop the projection and change it, then I start it again. The additional events are simply attached to the back. As a result, the attached events are not sorted correctly and become unusable.
  2. I stop the projection, change it and reset it. All events will be delivered again but are sorted correctly.

According to which pattern do you change your projections? Is it maybe bad practice to change projections at all?

Both of these are valid options, it depends on the change and your requirements … no?

Hello! I had the same problem. What I did was: deleted my projection added this one:

fromAll()
    .when({
        $any: (s, e) => {
            if (e.streamId.substring(0, 1) === '$')
                return;

            linkTo('all', e);
       }
})

You would never miss a bounded context stream again.

Just subscribe all your handlers, and make endpoints smart, and pipes dumb, as someone said.

There is no such thing as “changing a projection” its a new projection…

Trust me your life will be much easier.

Can you elaborate please?

Once you have a projection (this is projections in general not just eventstore projections!) there is no such thing as changing it. There is only having a new projection.

Let me give a concrete example.

fromAll().

when(

$any : function(s,e) { s.count++ }

)

easy enough

What if I changed it to :

fromAll().

when(

$any : function(s,e) {
if(e.something.contains(“shitbird”)) s.count++
}

)

:wink: