val results = transaction {
from(table)(r => select(t)).toList
}
val results = transaction {
from(table)(r => select(t)).toStream
}
results match {
case h #:: t => // Causes an exception
...
implicit def pagedStreamer[T](query: => Query[T]) = new {
def asStream(pageSize: Int): Stream[T] = next(List(), 0, pageSize)
private def next(currentSet: List[T], offset: Int, pageSize: Int): Stream[T] = currentSet match {
case h :: t => h #:: next(t, offset, pageSize)
case _ =>
transaction { query.page(offset, pageSize).toList } match {
case Nil => Stream.empty
case nextPage => next(nextPage, offset + pageSize, pageSize)
}
}
}