插入后如何返回多个值? [英] How to return multiple values after insert?
本文介绍了插入后如何返回多个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是Slick 2.0.
It's Slick 2.0.
我有以下内容:
mytable
.returning(mytable.map(_.id))
.+=(item)(session)
我希望插入不仅返回id
,而且返回name
字段和lastname
字段.可以在Slick中使用吗?
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?
推荐答案
map
确定返回表的投影,因此您可以选择所需的字段并将它们打包在元组中.
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)
这篇关于插入后如何返回多个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文