Slick 3.0删除并返回值

时间:2015-08-20 16:42:27

标签: scala slick-3.0

如果我想在插入新行时返回值,我可以执行类似

的操作
<target name="run" description="Run the jar file" depends="jar" >
    <java jar="build/jar/RunningPower.jar" fork="true">
        <classpath>
            <fileset dir="${lib.dir}">
            <include name="**/*.jar" /> 
            </fileset> 
        </classpath>
    </java>
</target>

删除时如何达到同样的效果?

我试过

BUILD FAILED
C:\Users\dt208672\Perforce\depot\ebill\Automation\Selenium_eBill\RunningPower\build.xml:37: Problem: failed to create task or type classpath
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

但显然这不会编译。

我可以诉诸val insertQuery = myTable returning myTable.map(_.id) += SomeData(someString) 理解,但我想知道是否有更短的方法。

1 个答案:

答案 0 :(得分:3)

我知道这样做的最好方法是做一些事情:

val query = db.filter(....)
val action = for {
   results <- query.result
   _ <- query.delete
} yield results
db.run(action.withTransactionIsolation(TransactionIsolation.RepeatableRead))
希望它更短。