Socket
Socket
Sign inDemoInstall

rheactor-event-store

Package Overview
Dependencies
7
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rheactor-event-store

Implementation of an event store based on redis


Version published
Weekly downloads
19
increased by216.67%
Maintainers
4
Install size
395 kB
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 21 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc