Packages

object DBIOAction

Source
DBIOAction.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DBIOAction
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. implicit def catsMonadErrorForDBIOEffect[E <: Effect]: MonadError[[A]DBIOAction[A, NoStream, E], Throwable]

    cats instance for values typed with the DBIOEffect[E, *] alias, for any effect E.

    cats instance for values typed with the DBIOEffect[E, *] alias, for any effect E. This covers DBIO (which is DBIOEffect[Effect.All, *]) and the results of the standard combinators. It lives here because the implicit scope of an alias is that of its expansion, DBIOAction[R, NoStream, E]. See DBIOBase.

  6. implicit def catsMonoidForDBIOEffect[E <: Effect, A](implicit A: Monoid[A]): Monoid[DBIOEffect[E, A]]

    cats Monoid for DBIOEffect[E, A] (including DBIO[A]) when A has a Monoid: x |+| y runs x, then y, and combines the results; empty is a successful action returning Monoid[A].empty.

  7. implicit def catsSemigroupForDBIOEffect[E <: Effect, A](implicit arg0: Semigroup[A]): Semigroup[DBIOEffect[E, A]]

    cats Semigroup for DBIOEffect[E, A] (including DBIO[A]) when A has a Semigroup.

    cats Semigroup for DBIOEffect[E, A] (including DBIO[A]) when A has a Semigroup. When A has a Monoid, the Monoid instance below is more specific and is chosen.

  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  9. def defer[R, S <: NoStream, E <: Effect](a: => DBIOAction[R, S, E]): DBIOAction[R, S, E]

    Suspend the construction of an action until it is run.

    Suspend the construction of an action until it is run. The by-name argument is not evaluated when defer is called but each time the resulting action is run, and the action it produces is then run in its place, with the same result, streaming and effect types. An exception thrown while evaluating the argument fails the resulting action instead of propagating to the caller.

    // A new timestamp is computed for each run instead of once when the action is built
    val logRun: DBIO[Int] = DBIO.defer(runLog += java.time.Instant.now())

    This is equivalent to DBIO.unit.flatMap(_ => a) and corresponds to cats.Defer.defer and cats.effect.IO.defer. To lift a lazily computed value rather than an action, use DBIO.defer(DBIO.successful(v)).

  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  12. def failed(t: Throwable): DBIOEffect[Effect, Nothing]

    Create a DBIOAction that always fails.

  13. def fold[T, E <: Effect](actions: Seq[DBIOAction[T, NoStream, E]], zero: T)(f: (T, T) => T): DBIOEffect[E, T]

    Create a DBIOAction that runs some other actions in sequence and combines their results with the given function.

  14. def from[R](fa: Future[R]): DBIOEffect[Effect, R]

    Lift a scala.concurrent.Future into a DBIOAction.

    Lift a scala.concurrent.Future into a DBIOAction.

    This overload is provided for interop with Play / Akka / Pekko code that produces Future values. The Future is wrapped in cats.effect.IO.fromFuture so that it is executed on the CE3 compute pool and its cancellation semantics are respected.

    def callExternalService(): Future[String] = ???
    val action: DBIO[String] = DBIO.from(callExternalService())

    For lifting a CE3 effect use DBIO.from[F[_], R](fa: F[R]) directly.

    Warning — do not call db.run inside the lifted Future. See the DBIO.from[F[_], R] overload for a full explanation of why nested db.run calls can cause a deadlock.

  15. def from[F[_], R](fa: F[R]): DBIOEffect[Effect, R]

    Lift any F[R] effect (e.g.

    Lift any F[R] effect (e.g. cats.effect.IO[R]) into a DBIOAction.

    The effect is executed on the CE3 compute pool, outside of any JDBC blocking context. Use this to interleave effectful computations (logging, UUID generation, etc.) within a DBIO action chain without needing a separate flatMap over F.

    val action: DBIO[String] = for {
      id <- DBIO.from(IO(java.util.UUID.randomUUID().toString))
      _  <- users += User(id, "Alice")
    } yield id

    Warning — do not call db.run inside the lifted effect. db.run acquires a connection-pool permit for the full duration of the outer action. Calling db.run again from within DBIO.from attempts to acquire a second permit from the same bounded pool. If all permits are already held by outer actions, every inner db.run will block forever, deadlocking the application. Compose database work as a single DBIO chain instead:

    // Wrong — nested db.run can deadlock:
    DBIO.from(db.run(otherAction))
    
    // Correct — compose as DBIO:
    otherAction.flatMap(result => nextAction(result))
  16. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def liftF[F[_], R](fa: F[R]): DBIOEffect[Effect, R]

    Alias for from.

    Alias for from.

    Warning — do not call db.run inside the lifted effect. See DBIO.from[F[_], R] for a full explanation of why nested db.run calls can cause a deadlock.

  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  23. def seq[E <: Effect](actions: DBIOAction[_, NoStream, E]*): DBIOEffect[E, Unit]

    A simpler version of sequence that takes a number of DBIOActions with any return type as varargs and returns a DBIOAction that performs the individual actions in sequence, returning () in the end.

  24. def sequence[R, M[+_] <: IterableOnce[_], E <: Effect](in: M[DBIOAction[R, NoStream, E]])(implicit cbf: Factory[R, M[R]]): DBIOEffect[E, M[R]]

    Transform a TraversableOnce[ DBIO[R] ] into a DBIO[ TraversableOnce[R] ].

  25. def sequenceOption[R, E <: Effect](in: Option[DBIOAction[R, NoStream, E]]): DBIOEffect[E, Option[R]]

    Transform a Option[ DBIO[R] ] into a DBIO[ Option[R] ].

  26. def successful[R](v: R): DBIOEffect[Effect, R]

    Lift a constant value to a DBIOAction.

  27. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  28. def toString(): String
    Definition Classes
    AnyRef → Any
  29. def traverse[A, B, M[+X] <: IterableOnce[X]](in: M[A])(f: (A) => DBIO[B])(implicit cbf: Factory[B, M[B]]): DBIO[M[B]]

    Transforms an IterableOnce[A] into a DBIO[IterableOnce[B]] using the provided function A => DBIO[B].

  30. def unit: DBIOEffect[Effect, Unit]

    A no-op DBIOAction.

    A no-op DBIOAction. A cached value of DBIOAction.successful(()) to avoid allocations.

  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  33. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from AnyRef

Inherited from Any

Ungrouped