import doobie.Transactor
import doobie.implicits._
import zio.interop.catz._
import zio.{Has, Task, ZIO}
package object repository {
type TranzactIO[T] = ZIO[Has[Transactor[Task]], Throwable, T]
def tzio[T](c: doobie.ConnectionIO[T]): TranzactIO[T] = {
for {
tx <- ZIO.service[Transactor[Task]]
res <- c.transact(tx)
.foldM(
e => Task.fail(e),
r => Task.succeed(r)
)
} yield res
}
}
I also use this repo
But was unable with upgrade to codebase working with cats-effect 3
And finally I just did a small change and all library does not make sense to be used in my project
Very little amount of code is required