Skip to content

gakuzzzz/free-scalikejdbc

Repository files navigation

ScalikeJDBC Composable DSL by Free Monad Build Status

  def createProgrammer[F[_]](name: Name, skillIds: List[SkillId])(implicit S: ScalikeJDBC[F], M: Applicative[Free[F, ?]]) = {
    import S._
    for {
      id     <- generateKey(insert.into(Programmer).namedValues(pc.name -> name))
      skills <- list(select.from(Skill as s).where.in(s.id, skillIds))(Skill(s))
      _      <- skills.traverse[Free[F, ?], Boolean](s => execute(insert.into(ProgrammerSkill).namedValues(sc.programmerId -> id, sc.skillId -> s.id)))
    } yield Programmer(id, name, skills)
  }
  val newProgrammer = DB.localTx {
    Interpreter.transaction.run(createProgrammer("Alice", List(2, 3)))
  }

About

ScalikeJDBC DSL by Free Monad

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages