How to read all entities from a Query[TableType] or from a Query[TableType, EntityType, Seq] in slick 3.0.0? In the tutorial there was "result" method, but it isn't defined after all the configurations.
Edit:
I've tried to use qbooks.result and (for(book <- qbooks) yield(book)).result from this model:
import java.sql.Date
import slick.driver.H2Driver.api._
import slick.backend.DatabasePublisher
import slick.driver.JdbcProfile
import entities._
object tables {
private val db = Database.forConfig("h2db")
//one of the table queries
val qbooks = TableQuery[Books]
db.run(
DBIO.seq(
qbooks.schema.create,
...
)
)
//one of the tables
class Books(tag: Tag) extends Table[Book](tag, "books") {
def isbn = column[Int]("isbn", O.PrimaryKey, O.AutoInc)
def author = column[String]("author")
def title = column[String]("title")
def year = column[Int]("edition_year")
def amount = column[Int]("amount")
def * = (isbn, author, title, year, amount) <>
(Book.tupled, Book.unapply)
}
val qbooks = TableQuery[Books]
appears to be a macro (do macros have to be enabled in the compiler?). I haven't used that syntax but the following compiles for me
//one of the table queries
object qbooks extends TableQuery[Books](tag ⇒ new Books(tag)) {
def all = qbooks.result
}
db.run(qbooks.all)
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