Slick + scala: get autoincremented id after saving -


this question has answer here:

i'm saving entity this:

def adduser(user: user) = {   val future = db.run(dbio.seq(     userqueue += user,     userqueue .result.map(println)   ))   await.result(future, duration.inf) }     

(where userqueue tablequery) , user not new autoincremented id. how can in automaticaly?

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


Comments