Seikho / evtstore

Event Sourcing and CQRS with Node.js and TypeScript
https://seikho.github.io/evtstore
63 stars 5 forks source link

How to pass transaction to be able to rollback a sequence of actions? #14

Open gtsamtsouris opened 1 year ago

gtsamtsouris commented 1 year ago

I am using the evtstore library in our app and I need a way to pass transaction in knex provider in order to rollback a sequence of actions in our application. Do you have any advice for it? After a small walkthrough in codebase it seems that I need to pass it only in the append function of the provider (where exists the only insertion in events table)

Seikho commented 1 year ago

I haven't quite been able to come up with a good/elegant solution for this. I'll keep thinking about it as I think it'd be quite valuable to have.

I assume you are needing to pass an arbitrary transaction while you're invoking commands?

gtsamtsouris commented 1 year ago

Correct. I have prepared a proof of concept about it on this https://github.com/Seikho/evtstore/pull/15 . Please have a look.

gtsamtsouris commented 1 year ago

Do you have any feedback about it?

Seikho commented 1 year ago

Apologies for the slow reply. Yes, I do. The library functions are intended to be "provider agnostic" so passing through provider-specific objects through the agnostic functions breaks that pattern.

We'll need to come up with a way to maintains the agnosticism of the library code while solving your problem.