I want to replicate the behaviour of the $by_category system projection however I’m not getting all the streams I’d expect
This is my user projection:
fromAll()
.when({
$any: function (s, e) {
if(e.streamId !== undefined && e.streamId !== null){
linkTo('$ce-' + e.streamId.split("-")[0], e);
}
}
});
Which works for most events, however it does not catch events created by this second projection:
if (true) {
linkTo('FOO-' + 12345, e);
}
I don’t get a $ce-FOO stream. I assume it’s because the $all filters the links, is that true and if so how can i work around this?
Thanks
What are you trying to achieve by replicating that behavior ?
Note:
linkTo('$ce-' + e.streamId.split("-")[0], e);
Don’t write to stream prefixed by $
directly, those are considered system streams and if appened by user code there is no guarentee what will happen later.
as for the behavior, the easiest is to look here :
using System;
using EventStore.Core.Services;
using EventStore.Projections.Core.Messages;
using EventStore.Projections.Core.Services;
using EventStore.Projections.Core.Services.Processing;
namespace EventStore.Projections.Core.Standard {
public class CategorizeStreamByPath : IProjectionStateHandler {
private readonly StreamCategoryExtractor _streamCategoryExtractor;
public CategorizeStreamByPath(string source, Action<string, object[]> logger) {
var extractor = StreamCategoryExtractor.GetExtractor(source, logger);
// we will need to declare event types we are interested in
_streamCategoryExtractor = extractor;
}
public void ConfigureSourceProcessingStrategy(SourceDefinitionBuilder builder) {
builder.FromAll();
builder.AllEvents();
builder.SetIncludeLinks();
This file has been truncated. show original