'Add metadata from projection

given following projection:

options({
    $includeLinks: false,
    reorderEvents: false,
    processingLag: 0
});

fromCategory('my_events')
    .partitionBy(({ data }) => data.Id)
    .when({
        $init: () => {
            return {
                data: {
                    Id: null,
                    Version: 0,
                    Key: null,
                    Title: null
                }
            };
        },
        ItemAdded: (state, { data }) => {
            state.data = {
                Version: state.data.Version + 1,
                ...data
            };

How can I write specific metadata to the output stream item_state-{0}? I'd basically like to avoid putting the relevant stuff to the state as I also want to directly process events on client side, where I have the required info in metadata.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source