com.augustnagro.magnum.ziomagnum

Members list

Value members

Concrete methods

def dataSourceLayer(jdbcUrl: String, username: String, password: String): ZLayer[Scope, IOException, HikariDataSource]

Creates a ZLayer that provides a DataSource using HikariCP.

Creates a ZLayer that provides a DataSource using HikariCP.

Attributes

def transaction[R <: DataSource, A](op: Connection ?=> RIO[R, A]): RIO[R, A]

Runs the operation in a transaction.

Runs the operation in a transaction.

If there is already a connection set on the fiber ref.

  • If auto-commit is enabled, we need to disable it and set it back to the previous value after the operation is done.
  • If auto-commit is disabled, we can just run the operation using the existing connection hence same transaction. else
  • Create a new connection using the DataSource in the fiber
  • Transaction will be committed or rolled back depending on the success/failure of the operation.
  • Will be removed from the fiber ref once the operation is done

Attributes

Extensions

Extensions

extension (frag: Frag)
def zQuery[A : DbCodec]: RIO[DataSource, Vector[A]]

Runs the query and returns a vector of results.

Runs the query and returns a vector of results.

Attributes

def zStream[A : DbCodec](fetchSize: Int): ZStream[DataSource, Throwable, A]

Runs the query and returns a stream of results.

Runs the query and returns a stream of results.

Value parameters

A

the type of the results.

fetchSize

the number of rows to fetch at a time from the database.

Attributes

def zUpdate: RIO[DataSource, Int]

Runs the update and returns the number of rows affected.

Runs the update and returns the number of rows affected.

Attributes

extension [R <: DataSource, A, K](repo: ImmutableRepo[A, K])
def zExistsById(id: K): ZIO[R, Throwable, Boolean]

Checks if a row with the given id exists in the table.

Checks if a row with the given id exists in the table.

Value parameters

id

The id of the row to check.

Attributes

def zFindAll: RIO[R, Vector[A]]

Finds all rows in the table.

Finds all rows in the table.

Attributes

def zFindAll(spec: Spec[A]): RIO[R, Vector[A]]

Finds all rows that match the given spec.

Finds all rows that match the given spec.

Value parameters

spec

The specification to use for filtering the results.

Attributes

def zFindAllById(ids: Set[K]): RIO[R, Vector[A]]

Finds all rows with the given ids.

Finds all rows with the given ids.

Value parameters

ids

The set of ids to find.

Attributes

def zFindById(id: K): RIO[R, Option[A]]

Finds a row by its id.

Finds a row by its id.

Attributes

def zcount: ZIO[R, Throwable, Long]

Counts the number of rows in the table.

Counts the number of rows in the table.

Attributes

extension [R <: DataSource, EC, A, K](repo: Repo[EC, A, K])
def zDeleteAll(set: Set[A]): RIO[R, Unit]

Deletes all rows in the table.

Deletes all rows in the table.

Value parameters

set

The set of elements to delete.

Attributes

def zDeleteAllById(ids: Set[K]): RIO[R, Unit]

Deletes all rows with the given ids.

Deletes all rows with the given ids.

Value parameters

ids

The set of ids to delete.

Attributes

def zDeleteById(id: K): RIO[R, Unit]

Counts the number of rows in the table.

Counts the number of rows in the table.

Attributes

def zInsert(a: EC): RIO[R, Unit]

Inserts a new row into the table.

Inserts a new row into the table.

Value parameters

a

The element to insert.

Attributes

def zInsertAll(set: Set[EC]): RIO[R, Unit]

Inserts all elements in the set into the table.

Inserts all elements in the set into the table.

Value parameters

set

The set of elements to insert.

Attributes

Returns

The inserted elements.

def zInsertAllReturning(set: Set[EC]): RIO[R, Vector[A]]

Inserts all elements in the set into the table

Inserts all elements in the set into the table

Value parameters

set

The set of elements to insert.

Attributes

Returns

The inserted elements.

def zInsertReturning(a: EC): RIO[R, A]

Inserts a new row into the table and returns the inserted element.

Inserts a new row into the table and returns the inserted element.

Value parameters

a

The element to insert.

Attributes

Returns

the inserted element.

def zTruncate(): RIO[R, Unit]

Truncates the table, removing all rows.

Truncates the table, removing all rows.

Attributes

def zUpdate(a: A): RIO[R, Unit]

Updates an existing row in the table.

Updates an existing row in the table.

Value parameters

a

The element to update.

Attributes

def zUpdateAll(set: Set[A]): RIO[R, BatchUpdateResult]

Updates all elements in the set.

Updates all elements in the set.

Value parameters

set

The set of elements to update.

Attributes

extension (update: Update)
def zrun[R <: DataSource]: RIO[R, Int]

Provides a ZIO-based update interface for the given Update.

Provides a ZIO-based update interface for the given Update.

Attributes