best event sourcing db strategy

后端 未结 6 801
误落风尘
误落风尘 2020-12-22 23:09

I want to setup a small event sourcing lib. I read a few tutorials online, everything understood so far.

The only problem is, in these different tutorials, there are

6条回答
  •  礼貌的吻别
    2020-12-22 23:39

    I read about an event-sourcing approach that consists in:

    1. having two tables: aggregate and event;
    2. base on you use cases either:

      a. creates and registry on aggregate table, generating an ID, version = 0 and a event type and create an event on event table;

      b. retrieve from aggregate table, events by ID or event type, apply business cases and then update aggregate table (version and event type) and then create an event on event table.

    although I this approach updates some fields on aggregate table, it leaves event table as append only and improves performace as you have the latest version of an aggregate in aggregate table.

提交回复
热议问题