Fork me on GitHub
#integrant
<
2021-02-18
>
richiardiandrea05:02:09

Hi there another question for this helpful group. I am trying to understand how to pass jdbc transactions to components like "repositories". It would mean replacing the db spec that I pass in at runtime but after the injection happens...thoughts?

richiardiandrea06:02:30

I am also using duct here and I wonder if modules could be used in order to augment the component with the transaction object before injection

sandqvist07:02:06

I recommend that you always pass the DB connection as a parameter to your repository functions. Inject your connection pool as close to the "input" side of your application. In a web app, I would inject it into the request object in a middleware. Then you can handle transactions normally (as in jdbc/with-db-transaction).

👍 3
richiardiandrea21:02:14

yeah the thing is we currently have a layer on top of the repositories...services and those gets the db injected and I am thinking of using with-transation within them...but then the repo's db has to come from them directly