doobie icon indicating copy to clipboard operation
doobie copied to clipboard

Request for best practices page in book of doobie

Open estsauver opened this issue 7 years ago • 2 comments

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

estsauver avatar Mar 28 '18 20:03 estsauver

  • How to throw an error inside connectionIO cio.flatMap(a => IO(something that throws).liftIO[ConnectionIO])

estsauver avatar Apr 03 '18 14:04 estsauver

  • 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

brinklec avatar Apr 05 '18 00:04 brinklec