I want to reuse code in my app,
for example, have functions like this
def getA1(idUser: Option[Long]) = {
val q = A1Q.filter(_.idUser === idUser.get)
Await.result(db.run(q.result), Duration.Inf)
}
def getA2[T](idUser: Option[Long]) = {
val q = A2Q.filter(_.idUser === idUser.get)
Await.result(db.run(q.result), Duration.Inf)
}
def getAn(idUser: Option[Long]) = {
val q = AnQ.filter(_.idUser === idUser.get)
Await.result(db.run(q.result), Duration.Inf)
}
A1Q has a type TableQuery
and 'q' has type Query[TA1Q, TA1Q#TableElementType, scala.Seq]
tried to use generic for solve current issue, like this
def execQ[T](q: Query[T, T, scala.Seq]) = Await.result(db.run(q.result), Duration.Inf)
but types mis much,
How can I generic Query[TA1Q, TA1Q#TableElementType, scala.Seq]
? in the correct way and prepare some separated function like
def execQ[T](q: Query[T, T, scala.Seq]) = Await.result(db.run(q.result), Duration.Inf)
BR!