slick-effect


License

License

GroupId

GroupId

com.kubukoz
ArtifactId

ArtifactId

slick-effect_2.11
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

slick-effect
slick-effect
Project URL

Project URL

https://github.com/kubukoz/slick-effect
Project Organization

Project Organization

com.kubukoz
Source Code Management

Source Code Management

https://github.com/kubukoz/slick-effect

Download slick-effect_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.kubukoz/slick-effect_2.11/ -->
<dependency>
    <groupId>com.kubukoz</groupId>
    <artifactId>slick-effect_2.11</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.kubukoz/slick-effect_2.11/
implementation 'com.kubukoz:slick-effect_2.11:0.3.0'
// https://jarcasting.com/artifacts/com.kubukoz/slick-effect_2.11/
implementation ("com.kubukoz:slick-effect_2.11:0.3.0")
'com.kubukoz:slick-effect_2.11:jar:0.3.0'
<dependency org="com.kubukoz" name="slick-effect_2.11" rev="0.3.0">
  <artifact name="slick-effect_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.kubukoz', module='slick-effect_2.11', version='0.3.0')
)
libraryDependencies += "com.kubukoz" % "slick-effect_2.11" % "0.3.0"
[com.kubukoz/slick-effect_2.11 "0.3.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
com.typesafe.slick : slick_2.11 jar 3.3.2
org.typelevel : cats-effect_2.11 jar 2.0.0

test (4)

Group / Artifact Type Version
org.typelevel : cats-testkit_2.11 jar 2.0.0
org.typelevel : cats-effect-laws_2.11 jar 2.0.0
com.h2database : h2 jar 1.4.200
org.typelevel : cats-testkit-scalatest_2.11 jar 1.0.0-RC1

Project Modules

There are no modules declared in this project.

slick-effect

License

Compatibility tools for Slick + cats-effect. Released for Scala 2.12 and 2.11.

Usage

Add the dependency. SBT:

"com.kubukoz" %% "slick-effect" % "0.3.0"

Ammonite:

$ivy.`com.kubukoz::slick-effect:0.3.0`

Coursier:

com.kubukoz::slick-effect:0.3.0

Instances

Import the instances:

import slickeffect.implicits._

//an implicit EC is needed for cpu-bound work on DBIOs (map, flatMap)
import scala.concurrent.ExecutionContext.Implicits.global

//the instances will be in implicit scope
scala> Async[slick.dbio.DBIO]
res0: Async[slick.dbio.package.DBIO] = slickeffect.DBIOAsync@434c179e

[EXPERIMENTAL] Transactor (from 0.3.0-M2 onwards)

You can use slick-effect to run your DBIOs. This functionality is experimental, and the API may change.

If you still want to use it, add a dependency on the transactor module:

"com.kubukoz" %% "slick-effect-transactor" % "0.3.0"

Create a transactor:

val transactorResource: Resource[IO, Transactor[IO]]
  .fromDatabase[IO](IO(Database.forURL("jdbc:h2:mem:"))) //or .fromDatabaseConfig
  .map(_.configure(config.transactionally)) //or any DBIO ~> DBIO
  .use(_.transact(action))


val result: DBIO[Int] = ???

transactorResource.use { tx =>
  tx.transact(result): IO[Int]
}

Versions

Version
0.3.0
0.3.0-M3
0.3.0-M2
0.3.0-M1
0.2.0-M1
0.1.0