How do I ignore event type $metadata?

In the docs, it says that projections will still receive a streams metadata events and that I should ignore event types of $metadata, but then it doesn’t say how to that. How do I ignore event types in evenstore (javascript) projections?

What we’re actually trying to solve is: we deleted a stream and a projection faulted with some errors saying that certain events were already processed. I’m assuming what’s happening is that tombstone events were created and are now being sent through the projection, and the projection is looking at the index or event number or something and since they’ve already been processed, it’s faulting. If that is true, then I suppose I just need to ignore those types but I’m unclear as to how.

You can ignore all system events by an if statement (startsWith("$"))

So, dumb question: where in the projection would it go? My projection is setup like fromCategory(...).forEachStream(...).when(...).outputState()

in your .when()

But most projections are pattern matched anyways by event type if doing a fromAll().when({$any : …) then inside the function defined.

I see. So when events are deleted, what’s actually happening to them with regards to the projection? is UserCreated being run through the projection again but with ‘$’ prepended to it? Does $UserCreated still get matched with the handler for UserCreated meaning I need to check for that buck in every handler? Is there a way to ignore that for the entire projection? I assume that’s what you were getting at with $any, but it’s also unclear how that works…

Is are all events run through $any even if there’s a specific handler for it? For example if the event UserCreated is received by the projection does it run through $any as well as UserCreated: function(s, e) ? Or is it one or the other? I apologize, the documentation is sparse when it comes to these details. :slight_smile: