Last active
April 5, 2022 06:56
-
-
Save supermanue/8deeec15f2f67115b8256a00bbefe199 to your computer and use it in GitHub Desktop.
Persistence Service
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
final class DoobiePersistenceService(tnx: Transactor[Task]) extends StoragePort { | |
import DoobiePersistenceService._ | |
override def create(user: User): IO[AppError, User] = | |
SQL | |
.create(UserStored.fromDomainUser(user)) | |
.run | |
.transact(tnx) | |
.foldM(err => IO.fail(DBError(err.getMessage)), _ => IO.succeed(user)) | |
override def get(id: Int): IO[AppError, User] = ??? //implemented in GH repo | |
override def delete(id: Int): Task[Boolean] = ??? //implemented in GH repo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment