如何从playframework对象中的光滑分组结果?

时间:2017-10-10 10:36:11

标签: scala playframework slick

这是Mycode:

case class Tabel1(id: Int, name: Option[String])
object Table1Table {
  class Table1Table(tag: Tag) extends Table[Tabel1](tag, "new_table") {    
    def id = column[Int]("id", O.AutoInc, O.PrimaryKey)
    def name = column[Option[String]]("new_table_col")    
    def * = (id, name) <> (Tabel1.tupled, Tabel1.unapply)
  }
  val tabel = TableQuery[Table1Table]
}    
val table2 = (for {
 (oX) <- Table1Table.tabel
} yield (oX))
.groupBy(?????); //group by

我有示例数据:

Tabel1(1,Some(new_table 1))
Tabel1(1,Some(new_table 5))
Tabel1(2,Some(new_table 2))
Tabel1(3,Some(new_table 3))
Tabel1(4,Some(new_table 4))

我想结果:

Tabel1(1,Some(new_table 1))// first or last
Tabel1(2,Some(new_table 2))
Tabel1(3,Some(new_table 3))
Tabel1(4,Some(new_table 4))

如何使用结果对象名称&#39; oX&#39;?

进行分组

0 个答案:

没有答案