我发现了许多关于“旧”AutoInc函数如何工作的旧帖子,但几乎没有关于新AutoInc函数实际工作方式的帖子。
有两个用用户和图片定义的私有AutoInc函数:
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
}我在returning上找到了http://slick.typesafe.com/doc/2.0.0/queries.html#inserting方法
但是这个into函数是什么呢?是干什么的呢?它会带来什么呢?
这是我的课,我该怎么写我自己的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 _)
}发布于 2014-02-22 22:33:35
它允许您将插入的值和生成的键映射到所需的目标值。
到目前为止都是没有文件的。我用文档创建了一个PR:https://github.com/slick/slick/pull/687
https://stackoverflow.com/questions/21960534
复制相似问题