How to return multiple values after insert?

2019-08-11 00:00发布

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条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-11 00:51

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)
查看更多
登录 后发表回答