title: Slick 3.0 Insert and then get Auto Increment Value
body: <p>I have written this code which works perfectly</p>
  
  <pre><code>class Items(tag: Tag) extends Table[Item](tag, "ITEMS") {
    def id = column[Long]("ITEMS_ID", O.PrimaryKey, O.AutoInc)
    def name = column[String]("ITEMS_NAME")
    def price = column[Double]("ITEMS_PRICE")
    def * = (id, name, price) &lt;&gt; ((Item.apply _).tupled, Item.unapply _)
  }
  
  object Shop extends Shop{
    val items = TableQuery[Items]
    val db = Database.forConfig("h2mem1")
  
    def create(name: String, price: Double) : Int = {
      val action = items ++= Seq(Item(0, name, price))
      val future1 = db.run(action)
      val future2 = future1 map {result =&gt; 
        result map {x =&gt; x}
      }
      Await.result(future2, Duration.Inf).getOrElse(0)
    }
  }
  </code></pre>
  
  <p>This code works but the return value is number of records inserted. But I want to return the value of the AutoInc after the insert has been done.</p>
  
  <p>i did google and found few articles</p>
  
  <p><a href="https://stackoverflow.com/questions/30421109/slick-3-0-0-autoincrement-composite-key">Slick 3.0.0 AutoIncrement Composite Key</a></p>
  
  <p><a href="https://stackoverflow.com/questions/23924686/returning-the-auto-incrementing-value-after-an-insert-using-slick">Returning the auto incrementing value after an insert using slick</a></p>
  
  <p>But somehow these do not answer the question cleanly.</p>