zio-jooq


License

License

Categories

Categories

jOOQ Data Databases
GroupId

GroupId

ch.j3t
ArtifactId

ArtifactId

zio-jooq_2.12
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

zio-jooq
zio-jooq
Project URL

Project URL

https://github.com/Shastick/zio-jooq/
Project Organization

Project Organization

j3t
Source Code Management

Source Code Management

https://github.com/Shastick/zio-jooq.git

Download zio-jooq_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/ch.j3t/zio-jooq_2.12/ -->
<dependency>
    <groupId>ch.j3t</groupId>
    <artifactId>zio-jooq_2.12</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/ch.j3t/zio-jooq_2.12/
implementation 'ch.j3t:zio-jooq_2.12:0.2.0'
// https://jarcasting.com/artifacts/ch.j3t/zio-jooq_2.12/
implementation ("ch.j3t:zio-jooq_2.12:0.2.0")
'ch.j3t:zio-jooq_2.12:jar:0.2.0'
<dependency org="ch.j3t" name="zio-jooq_2.12" rev="0.2.0">
  <artifact name="zio-jooq_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='ch.j3t', module='zio-jooq_2.12', version='0.2.0')
)
libraryDependencies += "ch.j3t" % "zio-jooq_2.12" % "0.2.0"
[ch.j3t/zio-jooq_2.12 "0.2.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.12

provided (3)

Group / Artifact Type Version
org.jooq : jooq jar 3.13.4
com.zaxxer : HikariCP jar 3.4.5
dev.zio : zio_2.12 jar 1.0.1

test (3)

Group / Artifact Type Version
dev.zio : zio-test_2.12 jar 1.0.1
dev.zio : zio-test-sbt_2.12 jar 1.0.1
com.h2database : h2 jar 1.4.200

Project Modules

There are no modules declared in this project.

zio-jooq

Already using jOOq to run queries against your database from Scala? Quickly integrate existing code into your new ZIO App using zio-jooq.

This lib essentially helps you quickly wrap ZIO's effectBlocking() around everything that is called on a DSLContext.

Usage

val zDb = ZDb.fromDslContext(ctxt)
// alternatively:
    zDb = ZDb.fromDataSource(...)
    zDb = ZDb.fromConnection(...)
    zDb = ZDb.singleConnection(...)  
    zDb = ZDb.pooledConnections(...)

for {
  r1 <- zDb.of(_.select(field).from(table).fetch())
} yield r1

The artifact coordinates are:

libraryDependencies += "ch.j3t" %% "zio-jooq" % version

Check over here for all available versions

Connection Pooling

You will need the hikariCp jars on the classpath if you intend to use the pooledConnections variants: zio-jooq is built against version 3.4.5

About

This is an admittedly (very) thin wrapper around jOOq to let it work with ZIO. While it originates in a desire to learn more about ZIO, it also serves a real purpose in some codebases that rely on jOOq and are integrating ZIO.

Please note that it is a work in progress.

Disclaimer

This project stems from a particular way of using jOOq: if your use case is not covered, you're welcome to implement it or fill an issue.

Additionally, I'm still pretty new to ZIO, so this library might not be the most idiomatic. Here again, comments are more than welcome.

Considerations

Why not directly use something like Doobie?

There are two reasons why Doobie is not involved here:

  • I only recently discovered that library, and don't know enough of it to make something useful out of it
  • zio-jooq is about letting you reuse as much as possible of the code you already have in a more ZIO'ish way.

It's a bit early at this point to work on replacing Jooq's JDBC plumbing with Doobie, though it's a thought that is worth entertaining.

This looks like a super small lib...

Yes, it is! Honestly, it's probably better to copy paste it than to rely on it via traditional dependency management (Please don't quote me on that ;))

Versions

Version
0.2.0
0.1.0