Self-Study notes - Event sourcing in JavaScript

This is my self-study notes for the video Event sourcing in JavaScript by Fredrik Christenson.

What is event sourcing

When you have tracked all state-changes for a system, you can recreate that state.

Instead of reading and writing changes to a DB, we create an event describing the change to state, which then runs through a service that updates the db.

This allows you to keep track of everything that happened in temporal order.

Event sourcing Pros

  • We can see every event that changed our application state.
  • We can see the order of every event that changed application state.

Event sourcing Cons

  • Need to store more data
  • Existing db fields likely need to be updated with events and not directly, introducing a bit more complexity than doing it without event sourcing.
  • Addition code needs to be written and maintained.

As long as you have all your events you can recreate your entire db at any point in its existance.

Show Comments