rheactor-event-store

9.7.0 • Public • Published

rheactor-event-store

Build Status monitored by greenkeeper.io js-standard-style semantic-release Test Coverage Code Climate

NPM

Implementation of an event store based on redis.

Contains helper methods to manage secondary indices.

Versioning

Storing events per aggregate is done in a list per individual aggregate, the order of the insertion is guaranteed by using Redis lists. This gives use an version number per event for free.

Lets assume we want to create a user 17, we store a UserCreatedEvent for this aggregate id:

eventStore.persist(new ModelEvent('UserCreatedEvent', '17', {name: 'John'}))

If we add another event later:

eventStore.persist(new ModelEvent('UserNameUpdatedEvent', '17', {name: 'Mike'}))

this event will be appended to the list.

When aggregating the events, we can increase the version of the aggregate per event.

Mutable Aggregates have been deprecated

The initial implementation of the event store modified models in place. More recently we decied to use immutable models instead.

The ImmutableAggregateRepository changes how Models are instantiated. It moves the responsibility of creating the model instance to the repository, where the applyEvent() method is invoked as a reducer. The method will return an instance of ImmutableAggregateRoot which can no longer be manipulated directly.

This also changes how meta information is stored in the Aggregates, it is now encapsuled in a separate object called AggregateMeta.

See the tests for details.

Readme

Keywords

none

Package Sidebar

Install

npm i rheactor-event-store

Weekly Downloads

5

Version

9.7.0

License

MIT

Unpacked Size

125 kB

Total Files

39

Last publish

Collaborators

  • resourcefuldevelopers
  • dam1r89