We use the readValues[T]()
to read single-column results:
import ba.sake.squery.{*, given}
def customersIds: List[Int] = ctx.run {
sql"SELECT id FROM customers".readValues[Int]()
}
There are also variations that return a single result, depending if you want an Option[T]
or T
:
sql"SELECT ...".readValueOpt[T]() : Option[T] // first result, if present
sql"SELECT ...".readValue[T]() : T // first result, or exception