thenativeweb / node-cqrs-domain

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

Can a command fire more than one event? #139

Open tommiii opened 5 years ago

tommiii commented 5 years ago

Can a command fire more than one event? Is that supported by the library? I've noticed a missmatch in the revision field when I fire 2 events from the same command, like if one revision is actually skipped.

e.g.: command 'openTask' could fire two events 'taskOpened' and 'urgentTaskOpened' if the task is urgent. If the aggregate 'task' has revision 'n' in this scenario, the 2 events will have revision 'n+2' into the eventstore

nanov commented 5 years ago

Of course it can, it is a pretty common situation, they are all committed in a single commit. The revision, however, is incremented with each single event.

ie. a revision is not skipped, the first event would have revision of previousRevision+1, the next one of previsousRevision+2, and the new state of the aggregate would have the same revision as the last event in the commit. This is the expected behaviour.

tommiii commented 5 years ago

We're not having the expected behaviour. Is there something we could missing?

nanov commented 5 years ago

I Really couldn't tell without at least seeing a snippet.

As this behaviour is well tested ( on both eventstore and domain side ), I would guess that there is some kind of misunderstanding of the expected behaviour.