I have table definition in Slick:
object ADB {
extends BaseDB[A]("a")
with PostgresDriver{
def id = column[Long]("id", O.PrimaryKey)
def name = column[String]("name")
...
def * = id ~ name ~ ... <> (A.apply _, A.unapply _)
def forSelect = id ~ name
}
Is it possible to refer to forSelect when querying for A?
I want to keep the list of field to be selected in one place to be able to push forSelect to trait in future.
I believe you can accomplish what you want like this:
( for( a <- ADB ) yield a.forSelect ).list
The difference between this and what stefan.schwetschke posted is that I'm using the instance a to reference forSelect instead of accessing it from the ADB object itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With