2016-04-26 7 views
1

Ich habe eine MySQL Tabelle alsSlick: Wie Blob von MySQL zu lesen?

abgebildet
class HealthReport(tag: Tag) extends Table[(Int, Int, Int, String, Timestamp, Blob)](tag, "LogProcessorHealthReport") { 

    def id = column[Int]("id") 
    def usersId = column[Int]("Users_Id") 
    def tenantId = column[Int]("Tenant_Id") 
    def ecId = column[String]("EcId") 
    def reportedOn = column[Timestamp]("ReportedOn") 
    def healthInfo = column[Blob]("HealthInfo") 

    def * = (id, usersId, tenantId, ecId, reportedOn, healthInfo) 
} 

Ich möchte den Inhalt healthInfo lesen, wie kann ich das tun?

Dank

+0

das jemals herausgefunden? –

Antwort

0

Slick 2:

import slick.driver.MySQLDriver.simple._ 

val db = Database.forConfig("db") 
val fourthHealthInfo: Option[Blob] = db withSession { implicit session => 
    TableQuery[HealthReport].filter(_.id === 4).map(_.healthInfo).list.headOption 
} 
val healthInfos: List[Blob] = db withSession { implicit session => 
    TableQuery[HealthReport].map(_.healthInfo).list 
} 

Slick 3:

import slick.driver.MySQLDriver.api._ 

val db = Database.forConfig("db") 
val fourthHealthInfo: Future[Option[Blob]] = db run { 
    TableQuery[HealthReport].filter(_.id === 4).map(_.healthInfo).result.headOption 
} 
val healthInfos: Future[Seq[Blob]] = db run { 
    TableQuery[HealthReport].map(_.healthInfo).result 
}