slick_hlist

slick 使用hlist 用于超过22列

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 slick.collection.heterogeneous.{HNil}
slick.collection.heterogeneous.syntax._

class Invoice(tag:Tag) extends Table[String :: String :: String :: HNil](tag,"INVOICELOG"){

def logId = column[String]("LOGID")
def createDate = column[String]("CREATEDATE")
def invoiceId = column[String]("INVOICEID")

def * = logId :: createDate :: invoiceId :: HNil

}

val i = db.run(invoices.filter((i) => i.logId === "0af9de5ab5a9457a950ecd9a97ddbe80").result)

val t = Await.result(i, Duration.Inf)

type MyRow = String::String :: String :: HNil

val ssss = t.asInstanceOf[Seq[MyRow]]

println(ssss.head(0))

t.foreach((i) => {

i match {
case a::b::c::rest =>
println(a)
}

})

参考资料:
How to read an element from a Scala HList?
Using shapeless HLists with Slick 3
细谈Slick(6)- Projection:ProvenShape,强类型的Query结果类型

欢迎关注我的公众号:沉迷Spring
显示 Gitment 评论
0%