This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait DatabaseProvider { | |
def databaseProvider: DatabaseProvider.Service | |
} | |
object DatabaseProvider { | |
trait Service { | |
def db: UIO[BasicBackend#DatabaseDef] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zio.IO | |
trait AssetRepository { | |
def add(name: String, price: BigDecimal): IO[RepositoryFailure, AssetId] | |
def getById(id: AssetId): IO[RepositoryFailure, Option[Asset]] | |
def update(id: AssetId, name: String, price: BigDecimal): IO[RepositoryFailure, Unit] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val db = Database.forConfig("h2mem1") | |
val queryAction: DBIO[Option[Int]] = ... | |
val result: Future[Option[Int]] = db.run(queryAction) |
NewerOlder