How do you update multiple columns using Slick Lifted Embedding?

邮差的信 提交于 2019-12-17 21:55:02

问题


How do you update multiple columns using Slick Lifted Embedding ? This document doesn't say much.

I expected it to be something like this

Query(AbilitiesTable).filter((ab: AbilitiesTable.type) => ab.id === ability_id).map((ab: AbilitiesTable.type) => (ab.verb, ab.subject)).update("edit", "doc")

回答1:


I figured it out. It should be like this

val map = Query(AbilitiesTable)
  .filter(_.id === ability_id)
  .map(ab => ab.verb ~ ab.context)

map.update(("", ""))

Typesafe, why your documentation is so bad ? I have to Google pretty much every silly thing or dig through unit-tests for hours. Please improve it. Thanks.




回答2:


With Slick 2.x and 3.x, this way of writing it works:

Users.filter(_.id === filterId)
     .map(x => (x.name, x.age))
     .update(("john", 99))

Be careful to remember the extra parentheses if you are updating more than one property otherwise you might get a compiler warning.



来源:https://stackoverflow.com/questions/16757368/how-do-you-update-multiple-columns-using-slick-lifted-embedding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!