是否可以更新變量列表,哪個數字只有在運行時才知道slick 3.0?slick 3.0如何更新變量列表,哪個數字只在運行時才知道
以下是什麼例子我想要做的(不會編譯)
var q: Query[UserTable, UserTable#TableElementType, Seq] = userTable
var columns = List[Any]()
var values = List[Any]()
if (updateCommands.name.isDefined) {
columns = q.name :: columns
values = updateCommands.name.get :: values
}
if (updateCommands.surname.isDefined) {
columns = q.surname :: columns
values = updateCommands.surname.get :: values
}
q = q.filter(_.id === updateCommands.id).map(columns).update(values)
我認爲最後一行將每個動作都使用自己的事務。要對整個操作序列執行相同的事務,我們應該使用:'slickDb.run(DBIO.seq(actions:_ *)。transactionally)' –
如何檢查事務結果?從剛剛運行一個更新,您將獲得修改的行數。 – spydon