Search code examples
playframeworkplayframework-2.0slick

slick getting autoincrement id


is there a way to get right after inserting data via slick the autoincrement ID of this dataset?

val result: Future[Option[ProcessTemplatesModel]] = db.run(p).map(id => {
  Some(process)
})

Thanks


Solution

  • To get autoincrement id after insertion, you can use the following code from the slick documentation

    val userId = (users returning users.map(_.id)) += User(None, "Stefan", "Zeiger")