All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.kodeworks.kvarg.util.Db.scala Maven / Gradle / Ivy

There is a newer version: 0.7
Show newest version
package no.kodeworks.kvarg.util

import slick.basic.DatabaseConfig
import slick.jdbc.JdbcProfile

//TODO we would like to move away from macro annotations to implement this, but the ways of slick are intricate..
trait Db extends DateImplicits {
  val dbCfg: DatabaseConfig[JdbcProfile]

  import dbCfg.profile.api._

  def tableQuerys: List[TableQuery[_ <: Table[_]]] = Nil

  def tables: Map[String, TableQuery[_ <: Table[_]]] = Map.empty
}

//
//class Tab[Entity](tag: Tag, name: String) extends Table[Entity](tag, name) {
//  implicit def tab: Tab[Entity] = this
//
//  def reps[
//  EntityGen <: HList
//  ]
//  (implicit
//   tt: TypeTag[Entity]
//   , ct: ClassTag[Entity]
//   , gen: Generic.Aux[Entity, EntityGen]
//   , reps: Reps[Entity, EntityGen]
//  ): reps.AsReps =
//    reps.reps
//
//  override def * : ProvenShape[Entity] = ???
//}

//
//object Tab {

//  def apply[Entity]
//  (implicit
//   mkTab: MkTab[Entity]
//  ): mkTab.type = mkTab
//}
//
//trait MkTab[Entity] {
//  def apply(): Tab[Entity]
//}
//
//object MkTab {
//  implicit def apply[
//  Entity
//  , EntityGen <: HList
//  ]
//  (implicit
//   tt: TypeTag[Entity]
//   , ct: ClassTag[Entity]
//   , gen: Generic.Aux[Entity, EntityGen]
//   , reps: Reps[Entity, EntityGen]
//   //   , shape: Shape[_ <: FlatShapeLevel, EntityRep, EntityGen, _]
//  )
//  = {
//    println("reps: " + reps.reps)
//    new MkTab[Entity] {
//      override def apply(): Tab[Entity] = {
//        val name = ReflectUtil.typeTagToSimpleName(tt)
//        println("name: " + name)
//
//        new Tab[Entity](null, name) {
//          //          implicit def s  = reps0.shape
//
//          def * : ProvenShape[Entity] = ??? //reps0.mappedWith(Generic[Entity])
//        }
//
//      }
//    }
//  }
//
//  implicit class TabOps[
//  Entity
//  , EntityGen <: HList
//  ](tab: Tab[Entity]) {
//    def reps
//    (implicit
//     gen: Generic.Aux[Entity, EntityGen]
//     , reps: Reps[Entity, EntityGen]
//    ): reps.AsReps =
//      reps.reps
//  }
//
//  sealed trait Reps[Entity, Values <: HList] {
//    type AsReps <: HList
//
//    def shape: Shape[_ <: FlatShapeLevel, AsReps, Values, _] = ???
//
//    def reps: AsReps
//  }
//
//  object Reps {
//    implicit def reps0[Entity]: Reps[Entity, HNil] = new Reps[Entity, HNil] {
//      override type AsReps = HNil
//
//      override def reps = HNil
//    }
//
//    implicit def reps1[
//    Entity,
//    ValuesH,
//    ValuesT <: HList
//    ]
//    (implicit
//     reps0: Reps[Entity, ValuesT]
//     , tab: Tab[Entity]
//     , typeType: TypedType[ValuesH]
//    )
//    : Reps[Entity, ValuesH :: ValuesT] = {
//      val n = "tablename"
//      val column: Rep[ValuesH] = tab.column[ValuesH]("asdf")
//      new Reps[Entity, ValuesH :: ValuesT] {
//        override type AsReps = Rep[ValuesH] :: reps0.AsReps
//
//        override def reps = column :: reps0.reps
//      }
//    }
//  }
//
//}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy