2016-04-26 7 views
1

は、私はそれをどのように行うことができ、私はhealthInfoの内容を読みたいSlick:MySQLからBlobを読み込むには?

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) 
} 

としてマッピングMySQLテーブルを持っていますか?

おかげ

+0

今までにこれを理解? –

答えて

0

スリック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 
} 

スリック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 
} 
関連する問題