Database

io.github.gaelrenoux.tranzactio.anorm.`package`.Database
object Database extends DatabaseModuleBase[Connection, ServiceOps[Connection], DbContext], DatabaseModuleTestOps[Connection, DbContext]

Database for the Anorm wrapper

Attributes

Graph
Supertypes
trait DatabaseModuleTestOps[Connection, DbContext]
class DatabaseModuleBase[Connection, ServiceOps[Connection], DbContext]
trait ModuleOps[Connection, ServiceOps[Connection]]
trait DatabaseOps[Connection, ServiceOps[Connection]]
class Object
trait Matchable
class Any
Show all
Self type
Database.type

Members list

Type members

Inherited types

type AnyDatabase = ServiceOps[Connection]

Attributes

Inherited from:
DatabaseModuleTestOps
type Service = ServiceOps[Connection]

Attributes

Inherited from:
DatabaseModuleBase

Value members

Concrete methods

final override def fromConnectionSource(implicit dbContext: DbContext, trace: Trace): ZLayer[ConnectionSource, Nothing, Database]

Creates a Database Layer which requires an existing ConnectionSource.

Creates a Database Layer which requires an existing ConnectionSource.

Attributes

Definition Classes
DatabaseModuleBase
override def noConnection(implicit trace: Trace): ZIO[Any, Nothing, Connection]

A Connection which is incapable of running anything, to use when unit testing (and the queries are actually stubbed, so they do not need a Database). Trying to run actual queries against it will fail.

A Connection which is incapable of running anything, to use when unit testing (and the queries are actually stubbed, so they do not need a Database). Trying to run actual queries against it will fail.

Attributes

Definition Classes
DatabaseModuleTestOps

Inherited methods

override def autoCommit[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[Database & R, Either[DbException, E], A]

Provides that ZIO with a Connection. All DB action in the ZIO will be auto-committed. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

Provides that ZIO with a Connection. All DB action in the ZIO will be auto-committed. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

This method should be implemented by subclasses, to provide the connection.

Attributes

Definition Classes
DatabaseModuleBase -> DatabaseOps
Inherited from:
DatabaseModuleBase
final def autoCommitOrDie[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As autoCommit, but errors when handling the connections are treated as defects instead of failures.

As autoCommit, but errors when handling the connections are treated as defects instead of failures.

Attributes

Inherited from:
DatabaseOps
final def autoCommitOrDieStream[R, E, A](stream: => ZStream[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[R & R0, E, A]

As autoCommitOrDie, for ZStream instances instead of ZIO instances.

As autoCommitOrDie, for ZStream instances instead of ZIO instances.

Attributes

Inherited from:
DatabaseOps
final def autoCommitOrWiden[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As autoCommit, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

As autoCommit, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

Attributes

Inherited from:
DatabaseOps
final def autoCommitOrWidenStream[R, E >: DbException, A](stream: => ZStream[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[R & R0, E, A]

As autoCommitOrWiden, for ZStream instances instead of ZIO instances.

As autoCommitOrWiden, for ZStream instances instead of ZIO instances.

Attributes

Inherited from:
DatabaseOps
override def autoCommitStream[R, E, A](stream: => ZStream[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[Database & R, Either[DbException, E], A]

As autoCommit, for ZStream instances instead of ZIO instances.

As autoCommit, for ZStream instances instead of ZIO instances.

This method should be implemented by subclasses, to provide the connection.

Attributes

Definition Classes
DatabaseModuleBase -> DatabaseOps
Inherited from:
DatabaseModuleBase
final def fromDatasource(errorStrategies: ErrorStrategiesRef)(implicit dbContext: DbContext, trace: Trace): ZLayer[DataSource, Nothing, Database]

As fromDatasource, but provides a default ErrorStrategiesRef. When a method is called with no available implicit ErrorStrategiesRef, the ErrorStrategiesRef in argument will be used.

As fromDatasource, but provides a default ErrorStrategiesRef. When a method is called with no available implicit ErrorStrategiesRef, the ErrorStrategiesRef in argument will be used.

Attributes

Inherited from:
DatabaseModuleBase
final def fromDatasource(implicit dbContext: DbContext, trace: Trace): ZLayer[DataSource, Nothing, Database]

Commodity method: creates a Database Layer which includes its own ConnectionSource based on a DataSource. Most connection pool implementations should be able to provide you a DataSource.

Commodity method: creates a Database Layer which includes its own ConnectionSource based on a DataSource. Most connection pool implementations should be able to provide you a DataSource.

When no implicit ErrorStrategies is available, the default ErrorStrategies will be used.

Attributes

Inherited from:
DatabaseModuleBase
final def fromDatasourceAndErrorStrategies(implicit dbContext: DbContext, trace: Trace): ZLayer[DataSource & ErrorStrategies, Nothing, Database]

As fromDatasource(ErrorStrategiesRef), but an ErrorStrategies is provided through a layer instead of as a parameter.

As fromDatasource(ErrorStrategiesRef), but an ErrorStrategies is provided through a layer instead of as a parameter.

Attributes

Inherited from:
DatabaseModuleBase
def none(implicit trace: Trace): ZLayer[Any, Nothing, AnyDatabase]

A Database which is incapable of running anything, to use when unit testing (and the queries are actually stubbed, so they do not need a Database). Trying to run actual queries against it will fail.

A Database which is incapable of running anything, to use when unit testing (and the queries are actually stubbed, so they do not need a Database). Trying to run actual queries against it will fail.

Attributes

Inherited from:
DatabaseModuleTestOps
override def transaction[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[Database & R, Either[DbException, E], A]

Provides that ZIO with a Connection. A transaction will be opened before any actions in the ZIO, and closed after. It will commit only if the ZIO succeeds, and rollback otherwise. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

Provides that ZIO with a Connection. A transaction will be opened before any actions in the ZIO, and closed after. It will commit only if the ZIO succeeds, and rollback otherwise. Failures in the initial ZIO will be wrapped in a Right in the error case of the resulting ZIO, with connection errors resulting in a failure with the exception wrapped in a Left.

This method should be implemented by subclasses, to provide the connection.

Attributes

Definition Classes
DatabaseModuleBase -> DatabaseOps
Inherited from:
DatabaseModuleBase
final def transactionOrDie[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As transaction, but errors when handling the connections are treated as defects instead of failures.

As transaction, but errors when handling the connections are treated as defects instead of failures.

Attributes

Inherited from:
DatabaseOps
override def transactionOrDieStream[R, E, A](stream: => ZStream[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZStream[Database & R, E, A]

As transactionOrDie, for ZStream instances instead of ZIO instances.

As transactionOrDie, for ZStream instances instead of ZIO instances.

Attributes

Definition Classes
DatabaseModuleBase -> DatabaseOps
Inherited from:
DatabaseModuleBase
final def transactionOrWiden[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

As transaction, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

As transaction, but exceptions are simply widened to a common failure type. The resulting failure type is a superclass of both DbException and the error type of the inital ZIO.

Attributes

Inherited from:
DatabaseOps

Deprecated and Inherited methods

final def autoCommitOrDieR[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def autoCommitOrWidenR[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def autoCommitR[R, E, A](zio: => ZIO[Connection & R, E, A])(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, Either[DbException, E], A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def transactionOrDieR[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def transactionOrWidenR[R, E >: DbException, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, E, A]

Attributes

Deprecated
[Since version 4.0.0]
Inherited from:
DatabaseOps
final def transactionR[R, E, A](zio: => ZIO[Connection & R, E, A], commitOnFailure: => Boolean)(implicit errorStrategies: ErrorStrategiesRef, trace: Trace): ZIO[R & R0, Either[DbException, E], A]

Attributes

Deprecated
[Since version 0.4.0]
Inherited from:
DatabaseOps