Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 837 Bytes

README.md

File metadata and controls

18 lines (16 loc) · 837 Bytes

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)))
  }