0

I'm saving entity like this:

def addUser(user: User) = {
  val future = db.run(DBIO.seq(
    userQueue += user,
    userQueue .result.map(println)
  ))
  Await.result(future, Duration.Inf)
}    

(where userQueue is TableQuery) And user do not get new autoincremented ID. How can I get in automaticaly?

1 Answers1

1
Try this: 
def addUser(user: User) = {
    val future = db.run(userQueue returning userQueue.map(_.id) += user )
    Await.result(future, Duration.Inf)
}

For more details: http://slick.typesafe.com/doc/3.0.0/queries.html#index-16

Sky
  • 2,509
  • 1
  • 19
  • 28