关于mysql:处理Scala案例类中的类型Blob

Dealing With The Type Blob within Scala's Case Classes

我正在使用Scala和Anorm进行MySQL数据库的IO,到目前为止,每当我在数据库中创建表时,我都将其等效为case类,然后使用该case类的参数和隐式连接来执行通常的IO。

SQL:

1
Create Table User (id: Int(20), username: varchar(255), password: varchar(255))

scala:

1
case class User (id: Long, username: String, password: String)

问题:如果我想在数据库中添加类型为Blob的列(例如profilePic:Blob),我应该在case类中使用哪种类型?还是我需要与文件相关的IO有不同的工作流程?


Anorm文档中,可以将BLOB JDBC类型映射到Array[Byte]InputStream

https://www.playframework.com/documentation/2.4.x/Anorm