I have defined repository:
trait Repo[F[_]] {
def findAll: Stream[F, Stop]
}
and it's implementation:
class DoobieRepo[F[_]: Sync](xa: Transactor[F]) extends Repo[F] {
override def findAll: Stream[F, Stop] =
readAllStopsQ.stream.transact(xa).map{
case (id, names, direction, lat, lon, typ) => Stop(id, names.split('|').toList, direction, lat, lon, typ)
}
def readAllStopsQ =
sql"select * from stop".query[(String, String, String, Float, Float, String)]
}
In the application I'm doing following:
val transactor = Transactor.fromDriverManager[Task](
"org.postgresql.Driver",
"jdbc:postgresql:test",
"me",
""
)
val repo = new DoobieRepo[Task](transactor)
repo.findAll // Stream[Task, Stop]
The question is how can I for example print this to console? (In general do some action with extracted data)
I tried:
repo.findAll.map { x =>
println(x)
}
But unsuccessful