C
C#2y ago
dotnut

✅ Design decision over multiple inserts in a single command

Hi, any design suggestions on how to handle an update command from a mvc form which update needs to update 4 different tables? One way is to have a single handler that does all and thus controller invokes a single update service Another is to have multiple handlers to support each table update. In order to achieve SRP the latter seems alright, but I am uncertain as the update command I see as an atomic operation
8 Replies
phaseshift
phaseshift2y ago
You definitely want all the updates to be in a single transaction
dotnut
dotnut2y ago
I was not too confident around following CQRS as it denotes separation of concerns, and having a handler writing in 4 tables but going back to what you say and thinking of it as a single transaction I agree it makes sense thanks! how do you see transaction as single - as a single service handling it?
phaseshift
phaseshift2y ago
Yes, one composing service. It could just call methods on finer grained services, as long as the transaction doesn't interfere/get interrupted
dotnut
dotnut2y ago
so essentially if at any point something fails I have to fail the entire request right
phaseshift
phaseshift2y ago
Yes
dotnut
dotnut2y ago
I mean it does feel right just after a confirmation very interesting thank you, I appreciate your input not sure how that can be achieved though.. if I managed to write in 2 tables but not on the other 2.. how do I revert the previous 2 writes?
phaseshift
phaseshift2y ago
That's for the db to figure out You just need to cancel the transaction
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts