Skip to content

Instantly share code, notes, and snippets.

@cheptsov
Created August 19, 2015 14:33
Show Gist options
  • Save cheptsov/9541c9f816072eee030c to your computer and use it in GitHub Desktop.
Save cheptsov/9541c9f816072eee030c to your computer and use it in GitHub Desktop.
package models
import javax.inject.{Inject, Singleton}
import play.api.db.slick.{HasDatabaseConfigProvider, DatabaseConfigProvider}
import slick.driver.JdbcProfile
import scala.concurrent.ExecutionContext.Implicits.global
case class Group(id: Long = 0, name: String)
@Singleton()
class GroupsDAO @Inject()(val dbConfigProvider: DatabaseConfigProvider,
topicsDAO: TopicsDAO)
extends HasDatabaseConfigProvider[JdbcProfile] {
import driver.api._
val groups = TableQuery[GroupsTable]
val topics = TableQuery[topicsDAO.TopicsTable]
class GroupsTable(tag: Tag) extends Table[Group](tag, "groups") {
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
def name = column[String]("name")
def nameIndex = index("group_name_index", name, unique = true)
def * = (id, name) <>(Group.tupled, Group.unapply)
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment