doobie
doobie copied to clipboard
Request for best practices page in book of doobie
Per chat in gitter, it would be great to accumulate a list of best practices in doobie.
As some examples:
- tucking a way a Statements object that contains all of the sql for a DAO, ala, https://github.com/gemini-hlsw/gem/blob/master/modules/db/src/main/scala/gem/dao/UserDao.scala#L88.
- be parametric in F as long as you can
- something about managing transactor through the call stack / lifecycle
- How to throw an error inside connectionIO
cio.flatMap(a => IO(something that throws).liftIO[ConnectionIO])
- Consider developing custom typeclasses for similar database operations on different data in an application. Consider it more strongly the larger the application.
- Then, how to assure resolution of implicit Composites for generic code using such typeclasses, taking into account any effect of best-practice modularization and use of imports
- Consider stronger typing for database fields with reusable single-element case classes. Consider it more strongly the larger the application.
- Then, how to assure Composite resolution for case classes that use imported single-element case classes as elements