Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. package models
  2. // AUTO-GENERATED Slick data model
  3. /** Stand-alone Slick data model for immediate use */
  4. object Tables extends {
  5. val profile = slick.driver.MySQLDriver
  6. } with Tables
  7.  
  8. /** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */
  9. trait Tables {
  10. val profile: slick.driver.JdbcProfile
  11. import profile.api._
  12. import com.github.tototoshi.slick.MySQLJodaSupport._
  13. import org.joda.time.DateTime
  14. import slick.model.ForeignKeyAction
  15. // NOTE: GetResult mappers for plain SQL are only generated for tables where Slick knows how to map the types of all columns.
  16. import slick.jdbc.{GetResult => GR}
  17.  
  18. /** DDL for all tables. Call .create to execute. */
  19. lazy val schema: profile.SchemaDescription = User.schema
  20. @deprecated("Use .schema instead of .ddl", "3.0")
  21. def ddl = schema
  22.  
  23. /** Entity class storing rows of table User
  24. * @param id Database column id SqlType(BIGINT UNSIGNED), AutoInc, PrimaryKey
  25. * @param name Database column name SqlType(VARCHAR), Length(255,true), Default(None)
  26. * @param email Database column email SqlType(VARCHAR), Length(255,true), Default(None)
  27. * @param password Database column password SqlType(VARCHAR), Length(255,true), Default(None)
  28. * @param created Database column created SqlType(DATETIME), Default(None)
  29. * @param updated Database column updated SqlType(DATETIME), Default(None) */
  30. case class UserRow(id: Long, name: Option[String] = None, email: Option[String] = None, password: Option[String] = None, created: Option[DateTime] = None, updated: Option[DateTime] = None)
  31. /** GetResult implicit for fetching UserRow objects using plain SQL queries */
  32. implicit def GetResultUserRow(implicit e0: GR[Long], e1: GR[Option[String]], e2: GR[Option[DateTime]]): GR[UserRow] = GR{
  33. prs => import prs._
  34. UserRow.tupled((<<[Long], <<?[String], <<?[String], <<?[String], <<?[DateTime], <<?[DateTime]))
  35. }
  36. /** Table description of table User. Objects of this class serve as prototypes for rows in queries. */
  37. class User(_tableTag: Tag) extends Table[UserRow](_tableTag, "User") {
  38. def * = (id, name, email, password, created, updated) <> (UserRow.tupled, UserRow.unapply)
  39. /** Maps whole row to an option. Useful for outer joins. */
  40. def ? = (Rep.Some(id), name, email, password, created, updated).shaped.<>({r=>import r._; _1.map(_=> UserRow.tupled((_1.get, _2, _3, _4, _5, _6)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported."))
  41.  
  42. /** Database column id SqlType(BIGINT UNSIGNED), AutoInc, PrimaryKey */
  43. val id: Rep[Long] = column[Long]("id", O.AutoInc, O.PrimaryKey)
  44. /** Database column name SqlType(VARCHAR), Length(255,true), Default(None) */
  45. val name: Rep[Option[String]] = column[Option[String]]("name", O.Length(255,varying=true), O.Default(None))
  46. /** Database column email SqlType(VARCHAR), Length(255,true), Default(None) */
  47. val email: Rep[Option[String]] = column[Option[String]]("email", O.Length(255,varying=true), O.Default(None))
  48. /** Database column password SqlType(VARCHAR), Length(255,true), Default(None) */
  49. val password: Rep[Option[String]] = column[Option[String]]("password", O.Length(255,varying=true), O.Default(None))
  50. /** Database column created SqlType(DATETIME), Default(None) */
  51. val created: Rep[Option[DateTime]] = column[Option[DateTime]]("created", O.Default(None))
  52. /** Database column updated SqlType(DATETIME), Default(None) */
  53. val updated: Rep[Option[DateTime]] = column[Option[DateTime]]("updated", O.Default(None))
  54. }
  55. /** Collection-like TableQuery object for table User */
  56. lazy val User = new TableQuery(tag => new User(tag))
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement