Skip to content
Browse files

Add documentation for `into` method

  • Loading branch information
cvogt committed Feb 22, 2014
1 parent 929b7c5 commit 3555385edfba4182dd8b85fd1a6dfe098c2e267b
@@ -239,7 +239,11 @@ trait JdbcInvokerComponent extends BasicInvokerComponent{ driver: JdbcDriver =>
implicit val session: Backend#Session = null

* Specifies a mapping from inserted values and generated keys to a desired value.
* @param f Function that maps inserted values and generated keys to a desired value.
* @tparam R target type of the mapping
def into[R](f: (U, RU) => R) = createMappedKeysInsertInvoker[U, RU, R](tree, keys, f)

@@ -310,6 +310,14 @@ object LiftedEmbedding extends App {
println((users returning

val userWithId =
(users returning
into ((user,id) => user.copy(id=Some(id)))
) += User(None, "Stefan", "Zeiger")

class Users2(tag: Tag) extends Table[(Int, String)](tag, "users2") {
def id = column[Int]("id", O.PrimaryKey)
@@ -192,6 +192,12 @@ which must be the table's auto-incrementing primary key. If you ask for
other columns a ``SlickException`` is thrown at runtime (unless the database
actually supports it).

You can follow the ``returning`` method with the ``into`` method to map
the inserted values and the generated keys (specified in returning) to a desired value.
Here is an example of using this feature to return an object with an updated id:

.. includecode:: code/LiftedEmbedding.scala#insert3b

Instead of inserting data from the client side you can also insert data
created by a ``Query`` or a scalar expression that is executed in the
database server:

0 comments on commit 3555385

Please sign in to comment.
You can’t perform that action at this time.