Advertisement
Guest User

Untitled

a guest
Feb 17th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.70 KB | None | 0 0
  1. package models
  2.  
  3. import scala.slick.driver.PostgresDriver.simple._
  4.  
  5. import com.football.models.User.{DAO => UserDAO}
  6. import com.football.models.util.RandomString
  7.  
  8. case class UserSession(
  9.     sessionId: String = RandomString.randomAlphanumericString(32),
  10.     userId: Int,
  11.     expiration: Long
  12. )
  13.  
  14. object UserSession {
  15.  
  16.   object DAO extends Table[UserSession]("user_sessions") {
  17.  
  18.     def sessionId = column[String]("id", O.PrimaryKey)
  19.  
  20.     def userId = column[Int]("user_id")
  21.  
  22.     def expiration = column[Long]("expiration")
  23.  
  24.     def * = sessionId ~ userId ~ expiration <> (UserSession.apply _, UserSession.unapply _)
  25.  
  26.     def user = foreignKey("user_fk", userId, UserDAO)(_.id)
  27.  
  28.   }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement