这是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;?
进行分组