Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cfeltz34 opened this issue Mar 23, 2023 · 0 comments
Closed

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

cfeltz34 opened this issue Mar 23, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@cfeltz34
Copy link

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);
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants