thenativeweb / node-cqrs-eventdenormalizer

Node-cqrs-eventdenormalizer is a node.js module that implements the cqrs pattern. It can be very useful as eventdenormalizer component if you work with (d)ddd, cqrs, domain, host, etc.
http://cqrs.js.org/pages/eventdenormalizer.html
MIT License
38 stars 27 forks source link

Rebuild viewmodel with eventdenormalizer and node-eventstore #54

Closed josh0707 closed 7 years ago

josh0707 commented 7 years ago

Hello,

Thank you for your library.

I want to rebuild a viewmodel.

I can do it by using: eventdenormalizer.clear(function (err) {}); eventdenormalizer.replay([/* ordered array of events */], function (err) { if (err) { console.log(err); } });

I can query my events from node-eventstore using: es.getEvents()

However, I didn't find the solution to pass my events from the event store to my eventdenormalizer. Since eventdenormalizer subscribes to eventstore events, do I need to dispatch each event using eventstore.setEventToDispatched or is there another way?

Thanks.

Josh

adrai commented 7 years ago

It depends on your system but basically you need to wrap for example es.getEvents() with a rest service or a dedicated channel on the messageBus. Then when you want to rebuild you can ask that service to return your events by streaming or I would recommend to implement some sort of pagination...