Created
August 19, 2015 14:33
-
-
Save cheptsov/9541c9f816072eee030c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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