Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shastick/zio-jooq
Thin ZIO wrapper around jOOq. Easily mix your existing jOOq code into your ZIO App or Service.
https://github.com/shastick/zio-jooq
jooq scala zio
Last synced: 3 days ago
JSON representation
Thin ZIO wrapper around jOOq. Easily mix your existing jOOq code into your ZIO App or Service.
- Host: GitHub
- URL: https://github.com/shastick/zio-jooq
- Owner: Shastick
- License: apache-2.0
- Created: 2020-08-31T18:58:03.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-11T19:37:24.000Z (about 4 years ago)
- Last Synced: 2024-10-11T18:09:35.688Z (28 days ago)
- Topics: jooq, scala, zio
- Language: Scala
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `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
```scala
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](https://mvnrepository.com/artifact/ch.j3t/zio-jooq)
### 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 ;))