DDD Repositories and Transactions
Let’s say you’re ordering a pizza online and you get to select the toppings for your pizza. To store this information, the website uses two database tables: pizzas and toppings. The repositories to store these can be imagined like this: 1 2 pizzaRepository.CreatePizza(ctx, pizza) toppingsRepository.CreateToppings(ctx, pizza.ID, toppings) Theres a catch when you make the order: if the above two operations don’t happen in a transaction, and the latter fails, you can expect the pizza to be delivered — without toppings. 🧑🍳 ...