Skip to content

May be we can deprecate this repository #30

@kuzkdmy

Description

@kuzkdmy

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

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
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions