Skip to content

Commit

Permalink
docs: Add Doobie documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltotore committed Dec 27, 2023
1 parent 1a121db commit 416898e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 12 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,19 @@ ivy"io.github.iltotore::iron:version"

### Platform support

| Module | JVM | JS | Native |
|-----------------|-----|-----|--------|
| iron | ✔️ | ✔️ | ✔️ |
| iron-cats | ✔️ | ✔️ | ✔️ |
| iron-circe | ✔️ | ✔️ | ✔️ |
| iron-ciris | ✔️ | ✔️ | ✔️ |
| iron-decline | ✔️ | ✔️ | ✔️ |
| iron-jsoniter | ✔️ | ✔️ | ✔️ |
| iron-scalacheck | ✔️ | ✔️ ||
| iron-skunk | ✔️ | ✔️ | ✔️ |
| iron-zio | ✔️ | ✔️ ||
| iron-zio-json | ✔️ | ✔️ ||
| Module | JVM | JS | Native |
|-----------------|-----|----|--------|
| iron | ✔️ | ✔️ | ✔️ |
| iron-cats | ✔️ | ✔️ | ✔️ |
| iron-circe | ✔️ | ✔️ | ✔️ |
| iron-ciris | ✔️ | ✔️ | ✔️ |
| iron-decline | ✔️ | ✔️ | ✔️ |
| iron-doobie | ✔️ |||
| iron-jsoniter | ✔️ | ✔️ | ✔️ |
| iron-scalacheck | ✔️ | ✔️ ||
| iron-skunk | ✔️ | ✔️ | ✔️ |
| iron-zio | ✔️ | ✔️ ||
| iron-zio-json | ✔️ | ✔️ ||

## Adopters

Expand Down
69 changes: 69 additions & 0 deletions docs/_docs/modules/doobie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: "Doobie Support"
---

# Doobie Support

This module provides refined types Get/Put/Meta instances for [Doobie](https://tpolecat.github.io/doobie/).

## Dependency

SBT:

```scala
libraryDependencies += "io.github.iltotore" %% "iron-doobie" % "version"
```

Mill:

```scala
ivy"io.github.iltotore::iron-doobie:version"
```

### Following examples' dependencies

SBT:

```scala
libraryDependencies += "org.tpolecat" %% "doobie-core" % "1.0.0-RC4"
```

Mill:

```scala
ivy"org.tpolecat::doobie-core::1.0.0-RC4"
```

## Get/Put/Meta instances

```scala
import doobie.*
import doobie.implicits.*

import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.*
import io.github.iltotore.iron.doobie.given

opaque type CountryCode = Int :| Positive
object CountryCode extends RefinedTypeOps[Int, Positive, CountryCode]

opaque type CountryName = String :| Not[Blank]
object CountryName extends RefinedTypeOps[String, Not[Blank], CountryName]

opaque type Population = Int :| Positive
object Population extends RefinedTypeOps[Int, Positive, Population]

//Refined columns of a table
case class Country(code: CountryCode, name: CountryName, pop: Population)

//Interpolation with refined values
def biggerThan(minPop: Population) =
sql"""
select code, name, population, indepyear
from country
where population > $minPop
""".query[Country]
```

Example inspired by
[another one from Doobie's documentation](https://tpolecat.github.io/doobie/docs/06-Checking.html#checking-a-query).
1 change: 1 addition & 0 deletions docs/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ subsection:
- page: modules/circe.md
- page: modules/ciris.md
- page: modules/decline.md
- page: modules/doobie.md
- page: modules/jsoniter.md
- page: modules/skunk.md
- page: modules/scalacheck.md
Expand Down

0 comments on commit 416898e

Please sign in to comment.