How do I get the auto-incremented values for records inserted with Slick? The following code prints 1111. I would have expected it to print 1234
import scala.sli
According to SLICK Inserting document, you should define a method forInsert
looks like:
def forInsert = first ~ last <> (
{ t =>
User(None, t._1, t._2)},
{ (u: User) =>
Some((u.first, u.last))
}) returning id
To get result:
def save(user: User): User = {
val id = users.forInsert.insert(user)
new User(Some(id), user.first, user.last)
}