I found many old posts on how the "old" AutoInc function works, but there is almost no post on how the new AutoInc function actually works.
There are two private AutoInc functions defined with User and Picture:
private val picturesAutoInc = pictures
returning pictures.map(_.id) into { case (p, id) => p.copy(id = id) }
private val usersAutoInc = users.map(u => (u.name, u.pictureId))
returning users.map(_.id) into {
case (_, id) => id
}
I found the returning
method on http://slick.typesafe.com/doc/2.0.0/queries.html#inserting
But what is this into
function? What does it do? What does it take into?
This is my class and how should I write my own autoInc?
case class Label (id: Option[Int] = None, tag_name: String)
class Labels (tag: Tag) extends Table[Label](tag, "Labels") {
def id = column[Option[Int]]("TAG_ID", O.PrimaryKey, O.AutoInc)
def tag_name = column[String]("TAG_NAME")
def * = (id, tag_name) <> (Label.tupled, Label.unapply _)
}