Packages

package dbio

The dbio package contains the Database I/O Action implementation. See DBIOAction for details.

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

Type Members

  1. case class AndThenAction[R, +S <: NoStream, -E <: Effect](as: IndexedSeq[DBIOAction[Any, NoStream, E]]) extends DBIOAction[R, S, E] with Product with Serializable

    A DBIOAction that represents a seq or andThen operation for sequencing in the DBIOAction monad.

    A DBIOAction that represents a seq or andThen operation for sequencing in the DBIOAction monad. Unlike SequenceAction it only keeps the last result.

  2. case class AsTryAction[+R, -E <: Effect](a: DBIOAction[R, NoStream, E]) extends DBIOAction[Try[R], NoStream, E] with Product with Serializable

    A DBIOAction that represents an asTry operation.

  3. case class CleanUpAction[+R, +S <: NoStream, -E <: Effect](base: DBIOAction[R, S, E], f: (Option[Throwable]) => DBIOAction[_, NoStream, E], keepFailure: Boolean) extends DBIOAction[R, S, E] with Product with Serializable

    A DBIOAction that represents a cleanUp operation for sequencing in the DBIOAction monad.

  4. type DBIO[+R] = DBIOAction[R, NoStream, All]

    Simplified type for a DBIOAction without streaming or effect tracking

  5. sealed trait DBIOAction[+R, +S <: NoStream, -E <: Effect] extends DBIOBase[E, R] with Dumpable

    A Database I/O Action that can be executed on a database.

    A Database I/O Action that can be executed on a database. The DBIOAction type allows a separation of execution logic and resource usage management logic from composition logic. DBIOActions can be composed with methods such as andThen, andFinally and flatMap. Individual parts of a composite DBIOAction are always executed serially on a single database, but possibly in different database sessions, unless the session is pinned either explicitly (using withPinnedSession) or implicitly (e.g. through a transaction).

    The actual implementation base type for all Actions is DBIOAction. StreamingDBIO and DBIO are type aliases which discard the effect type (and the streaming result type in the latter case) to make DBIOAction types easier to write when these features are not needed. DBIOEffect[E, R] discards only the streaming result type and puts the result type last, so that it can be used with type classes such as cats.Monad; see DBIOBase. All primitive DBIOActions and all DBIOActions produced by the standard combinators in Slick have correct Effect types and are streaming (if possible).

    R

    The result type when executing the DBIOAction and fully materializing the result.

    S

    An encoding of the result type for streaming results. If this action is capable of streaming, it is Streaming[T] for an element type T. For non-streaming DBIOActions it is NoStream.

    E

    The DBIOAction's effect type, e.g. Effect.Read with Effect.Write. When composing actions, the correct combined effect type will be inferred. Effects can be used in user code, e.g. to automatically direct all read-only Actions to a slave database and write Actions to the master copy.

  6. sealed trait DBIOBase[-E <: Effect, +R] extends AnyRef

    The type class view of a DBIOAction: a binary type constructor DBIOBase[E, R] that keeps the effect type E and the result type R, in that order, and discards the streaming type, so that type class instances such as cats.MonadError can be defined for DBIOBase[E, *].

    The type class view of a DBIOAction: a binary type constructor DBIOBase[E, R] that keeps the effect type E and the result type R, in that order, and discards the streaming type, so that type class instances such as cats.MonadError can be defined for DBIOBase[E, *]. DBIOAction is its only implementation.

    On Scala 3 a DBIOAction[R, S, E] unifies with an F[_] type constructor as DBIOBase[E, *]: the compiler falls back to base types because the bounded effect parameter cannot be the hole of an unbounded F[_]. The instances defined in the DBIOBase companion are therefore found for any action, including the profile-specific subtypes returned by the lifted API and streaming actions, without an explicit upcast or import, and the effect is preserved: List(1, 2).traverse(i => table += i) is a DBIOBase[Effect.Write, List[Int]]. Values typed with the DBIOEffect[E, R] or DBIO[R] alias unify as that alias instead and use the instances in the DBIOAction companion. Scala 2 does not fall back to base types; there the instances are found for values typed with one of the aliases and for the results of the standard combinators whose result types are spelled with DBIOEffect. Any value whose static type is spelled as a full DBIOAction[R, S, E] needs toAction on Scala 2: the profile-specific actions of the lifted API, and the results of the combinators that keep the streaming type (flatMap, andThen, >>, for-comprehensions, transactionally, withPinnedSession, named, andFinally, cleanUp).

    Note: -source:3.0-migration disables the base type fallback.

    map, flatMap, andThen and >> are members of DBIOBase, so that a DBIOBase produced by a cats combinator composes with Slick's own combinators, including in for-comprehensions, and the effects of the parts are intersected as usual. A DBIOBase can also be passed to Database.run and every other place that accepts a DBIOAction, thanks to the implicit view DBIOBase.toAction, and the same view gives it the other members of DBIOAction such as transactionally, withPinnedSession and named. The JDBC profile's extension methods (transactionally(isolation), withStatementParameters) accept a DBIOBase directly. The explicit toAction remains for the cases no view reaches, e.g. a collection of DBIOBase values passed to DBIO.sequence.

    A cats type class is invariant in F, so the effect of the receiver of a cats combinator fixes F: readAction.flatTap(_ => writeAction) does not compile through cats. Use Slick's >> or flatMap, which intersect the effects, or ascribe the receiver to DBIO. Scala 3 infers the effect intersection for tupled, mapN, *> and sequence over mixed effects; Scala 2 requires the ascription there as well.

  7. type DBIOEffect[-E <: Effect, +R] = DBIOAction[R, NoStream, E]

    Simplified type for a DBIOAction without streaming but with effect tracking.

    Simplified type for a DBIOAction without streaming but with effect tracking. The result type is the last parameter, so that DBIOEffect[E, *] can be the F[_] of a type class such as cats.Monad; DBIO[R] is DBIOEffect[Effect.All, R]. See DBIOBase.

  8. trait DatabaseAction[+R, +S <: NoStream, -E <: Effect] extends DBIOAction[R, S, E]

    A DBIOAction that represents a database operation.

    A DBIOAction that represents a database operation. Concrete implementations are backend-specific.

  9. trait Effect extends AnyRef

    A phantom type for annotating DBIOActions with specific effects (e.g.

    A phantom type for annotating DBIOActions with specific effects (e.g. Write or Transactional). Effects can be composed through intersection types (e.g. Write with Transactional. The standard Slick back-ends do not restrict the evaluation of actions based on effects but they can be used in user-level code (e.g. for ensuring that all writes go to a master database but reads can also be performed by a slave).

  10. case class FailedAction[-E <: Effect](a: DBIOAction[_, NoStream, E]) extends DBIOAction[Throwable, NoStream, E] with Product with Serializable

    A DBIOAction that represents a failed operation.

  11. case class FailureAction(t: Throwable) extends SynchronousDatabaseAction[Nothing, NoStream, BasicActionContext, Effect] with Product with Serializable

    A DBIOAction that fails.

  12. case class FlatMapAction[+R, +S <: NoStream, P, -E <: Effect](base: DBIOAction[P, NoStream, E], f: (P) => DBIOAction[R, S, E]) extends DBIOAction[R, S, E] with Product with Serializable

    A DBIOAction that represents a flatMap operation for sequencing in the DBIOAction monad.

  13. case class LiftFAction[F[_], R](fa: F[R]) extends DBIOAction[R, NoStream, Effect] with Product with Serializable

    A DBIOAction that lifts an effectful computation F[R] (e.g.

    A DBIOAction that lifts an effectful computation F[R] (e.g. cats.effect.IO) into the DBIO monad. The effect is run on the CE3 compute pool, outside of any JDBC blocking context.

  14. case class NamedAction[+R, +S <: NoStream, -E <: Effect](a: DBIOAction[R, S, E], name: String) extends DBIOAction[R, S, E] with Product with Serializable

    A DBIOAction that attaches a name for logging purposes to another action.

  15. sealed trait NoStream extends AnyRef

    A phantom type used as the streaming result type for DBIOActions that do not support streaming.

    A phantom type used as the streaming result type for DBIOActions that do not support streaming. Note that this is a supertype of Streaming (and it is used in covariant position), so that any streaming action can be used where a non-streaming action is expected.

  16. case class PinnedSessionAction[+R, +S <: NoStream, -E <: Effect](inner: DBIOAction[R, S, E]) extends DBIOAction[R, S, E] with Product with Serializable

    A DBIOAction that pins the session for the duration of its inner action.

    A DBIOAction that pins the session for the duration of its inner action. All inner actions will share the same JDBC connection.

  17. case class SequenceAction[R, +R2, -E <: Effect](as: IndexedSeq[DBIOAction[R, NoStream, E]])(implicit cbf: Factory[R, R2]) extends DBIOAction[R2, NoStream, E] with Product with Serializable

    A DBIOAction that represents a sequence operation for sequencing in the DBIOAction monad.

  18. sealed trait Streaming[+T] extends NoStream

    A phantom type used as the streaming result type for DBIOActions that do support streaming.

  19. type StreamingDBIO[+R, +T] = DBIOAction[R, Streaming[T], All]

    Simplified type for a streaming DBIOAction without effect tracking

  20. case class SuccessAction[+R](value: R) extends SynchronousDatabaseAction[R, NoStream, BasicActionContext, Effect] with Product with Serializable

    A DBIOAction that returns a constant value.

  21. trait SynchronousDatabaseAction[+R, +S <: NoStream, -C <: BasicActionContext, -E <: Effect] extends DatabaseAction[R, S, E]

    A synchronous database action provides a function from a BasicActionContext to the result type.

    A synchronous database action provides a function from a BasicActionContext to the result type. BasicBackend.DatabaseDef.run supports this kind of action out of the box through BasicBackend.DatabaseDef.runSynchronousDatabaseAction so that run does not need to be extended if all primitive database actions can be expressed in this way. These actions also implement construction-time fusion for the andFinally, andThen, asTry, failed, withPinnedSession and zip operations.

    The execution engine ensures that a BasicActionContext is never used concurrently and that all state changes performed by one invocation of a SynchronousDatabaseAction are visible to the next invocation of the same or a different SynchronousDatabaseAction.

  22. case class TransactionalAction[+R, +S <: NoStream, -E <: Effect](inner: DBIOAction[R, S, E], isolationLevel: Option[Int]) extends DBIOAction[R, S, E] with Product with Serializable

    A DBIOAction that runs its inner action inside a database transaction.

    A DBIOAction that runs its inner action inside a database transaction. The interpreter commits on success and rolls back on failure or fiber cancellation. An optional JDBC transaction isolation level can be specified.

Value Members

  1. val DBIO: DBIOAction.type
  2. object DBIOAction
  3. object DBIOBase
  4. object Effect
  5. object SynchronousDatabaseAction

Inherited from AnyRef

Inherited from Any

Ungrouped