How to return multiple values after insert?

孤者浪人 提交于 2019-12-11 04:49:53

问题


It's Slick 2.0.

I have the following:

mytable
  .returning(mytable.map(_.id))
  .+=(item)(session)

I'd like the insert not only to return the id but also the name field and the lastname fields. Is it possible in Slick?


回答1:


map determines what projection of the table is returned, so you can pick the fields you need and pack them in a tuple:

mytable
  .returning(mytable.map(t => (t.id, t.name, t.lastname)))
  .+=(item)(session)


来源:https://stackoverflow.com/questions/27675813/how-to-return-multiple-values-after-insert

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