Skip to content

Database Splitting : create selector on type (SplitDiscriminator) #187

Closed
@cfeltz34

Description

@cfeltz34

I have a splitted database and I want to get all changes of a specific object :

await foreach (var change in _couchDBContext.ExampleDatas.GetContinuousChangesAsync(options: options, filter: filter, cancellationToken.Token))
{
     onChange(change);
}

onChange receive all database changes, not only change of my object type

I have a quick and safe fix, if you change
internal string SplitDiscriminator { get; set; }
by
public string SplitDiscriminator { get; internal set; }
But in any case, I think it would be nice to make this accessor available. Even if you make the correct correction.

I can create my own selector like this :
var filter = ChangesFeedFilter.Selector<TSource>(d => d.SplitDiscriminator == typeof(TSource).Name);

namespace ExampleApi.CouchDB
{
    public class CouchDBContext : CouchContext
    {
        public string DatabaseName = "example";

        protected ILogger _logger;
        public CouchDatabase<ExampleDataCouchDB> ExampleDatas { get; set; }
        public CouchDatabase<DesignDocument> ExampleDesign { get; set; }

        protected override void OnDatabaseCreating(CouchDatabaseBuilder databaseBuilder)
        {
            databaseBuilder.Document<ExampleDataCouchDB>().ToDatabase(this.DatabaseName);
            databaseBuilder.Document<DesignDocument>().ToDatabase(this.DatabaseName);
        }
    }
}

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions