oyvindberg / typo

Typed Postgresql integration for Scala. Hopes to avoid typos
https://oyvindberg.github.io/typo/
MIT License
99 stars 9 forks source link

Foreign keys in DSL #93

Closed oyvindberg closed 3 months ago

oyvindberg commented 4 months ago

these are generated in Fields objects so othey are accessible in DSL:

generated boilerplate:

  def fkEmployee: ForeignKey[EmployeeFields, EmployeeRow] =
    ForeignKey[EmployeeFields, EmployeeRow]("humanresources.FK_JobCandidate_Employee_BusinessEntityID", Nil)
      .withColumnPair(businessentityid, _.businessentityid)

usage:

      val query0 = productRepo.select
        .joinFk(_.fkProductmodel)(projectModelRepo.select)
        .joinFk(_._1.fkProductsubcategory)(productsubcategoryRepo.select)
        .joinFk(_._2.fkProductcategory)(productcategoryRepo.select)
      query0.toList.foreach(println)