Skip to content
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

write to different repositories for the same definition of the viewbuilder #71

Open
daschy opened this issue Jan 26, 2018 · 6 comments
Open

Comments

@daschy
Copy link

daschy commented Jan 26, 2018

In the same node instance I have:

  • 1 view builders (vb)
  • 2 mongo repositories: repomongoCustomer1, repomongoCustomer2
  • 2 denormalizers:
    - denomCustomer1 (that writes to repomongoCustomer1),
    • denomCustomer2 -> (that writes to repomongoCustomer2),
  • 1 eventstore. Each event in the eventstore contains a property customer that describes what denormalizer is in charge of the denormalization.

When I instantiate, in order, denomCustomer1 and denomCustomer2. Happens that the event is only written to the last repository (repomongoCustomer2) .

Is it possible to have multiple repository associated to multiple denormalizers, all created from the same viewBuilder?

Thanks

@daschy
Copy link
Author

daschy commented Jan 26, 2018

Just an update. I tried to duplicate the view builders, so now I have vbCustomer1 and vbCustomer2 and works as expected. It save the data to each repository correctly.

@adrai
Copy link
Contributor

adrai commented Jan 26, 2018

So it’s fine for you?

@daschy
Copy link
Author

daschy commented Jan 28, 2018

No really, in this way everytime I need to add a customer I have to duplicate the files, it can only be done by taking the server down. Is there another solution, without physically duplicating the files?

@adrai
Copy link
Contributor

adrai commented Jan 29, 2018

Not right now...
But open for a PR 😊
Perhaps a new function in the viewBuilder that verifies an prepares a repository by analyzing the event...
Or a new type of collection (a dynamic collection)

@adrai
Copy link
Contributor

adrai commented Jan 29, 2018

You only need a new collection on-the-fly right?
Not a complete new db...

@daschy
Copy link
Author

daschy commented Jan 29, 2018

I don't think that collection on the fly is what I need. I need the entire database everytime.

The use case is every time I do, on the same node instance:

const denormCustomer1 = new Denorm ({viewBuilder, repomongoCustomer1});
const denormCustomer2 = new Denorm ({viewBuilder, repomongoCustomer2})
msgbus.onEvent(event => {
        if ('customer1'=== event.data.customer) {
          denormCustomer1.handle(event);
        }else if ('customer2'=== event.data.customer) {
          denormCustomer2.handle(event);
       }
 });

It denormzalizes to repomongoCustomer1 or repomongoCustomer2 based on the info based on the event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants