Skip to content

v0.11.0 Cats effect IO API

Compare
Choose a tag to compare
@marcgrue marcgrue released this 27 Sep 14:00
· 39 commits to main since this release

Molecule now supports returning data wrapped in a cats.effect.IO by importing the relevant database and API. So now there are 4 APIs to choose from:

Synchronous

import molecule.sql.postgres.sync._
       
val persons: List[(String, Int, String)] =
  Person.name.age.Address.street.query.get

Asynchronous (Future)

import molecule.sql.postgres.async._

val persons: Future[List[(String, Int, String)]] =
  Person.name.age.Address.street.query.get

ZIO

import molecule.sql.postgres.zio._

val persons: ZIO[Conn, MoleculeError, List[(String, Int, String)]] =
  Person.name.age.Address.street.query.get

IO

import molecule.sql.postgres.io._ 

val persons: cats.effect.IO[List[(String, Int, String)]] =
  Person.name.age.Address.street.query.get

Same molecules

As you can see the molecules are identical for each API. The import determines the return type. Likewise, transaction reports are wrapped as the queries for each API.