User Defined Projection : Apply a projection on a set of streams with a specific pattern

from your example at https://eventstore.org/docs/projections/user-defined-projections/index.html

options({
    resultStreamName: "my_demo_projection_result",
    $includeLinks: false,
    reorderEvents: false,
    processingLag: 0
})

fromStream('account-1')
.when({
    $init:function(){
        return {
            count: 0
        }
    },
    myEventType: function(state, event){
        state.count += 1;
    }
})
.transformBy(function(state){
    state.count = 10;
})
.outputState()

Can you select with a most sophisticated selector like fromStream('account-{?d}') to apply that projection for each account ?

Use ‘fromCategory(“account”)’ and you’re set!

Just make sure to enable “by_category” system projection. https://eventstore.org/docs/projections/system-projections/index.html?tabs=tabid-5#by-category

ok, actually my issue is that I have 2 levels of category… “myStream-MyFisrtCategory_A-MySecondCategory_B” …I was fine before by having “myStreamMyFisrtCategory_A-MySecondCategory_B” because I was just playing on the second category…
Now I need to play on a set of “$ce-myStreamMyFisrtCategory_A”

I hope that my issue is clearer now :sweat_smile:

In your snippet, you only declared a single event type. So maybe you should focus on this and only ask for «$et-{your event type}» stream, which would give you all the events of a given type, regardless their streams.

If you need to support more event types, then I suggest you to use ‘fromAll()’ in your projection code.