Skip to content

Instantly share code, notes, and snippets.

@dsugden
Created January 21, 2013 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsugden/4582870 to your computer and use it in GitHub Desktop.
Save dsugden/4582870 to your computer and use it in GitHub Desktop.
val ArticleTable = new Table[Article]("Article") {
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
def name = column[String]("name")
def body = column[Option[String]]("body")
def publishedBody = column[Option[String]]("publishedBody")
def userID = column[Long]("user_Id")
def created = column[Date]("created")
def category = column[String]("category")
def published = column[Boolean]("published")
def displayOrder = column[Int]("displayOrder")
def userFK = foreignKey("USER_FK", userID, UserTable)(_.id)
def * = id.? ~ name ~ body ~ userID ~ created ~ category ~ published ~ displayOrder ~ publishedBody <> (Article, Article.unapply _)
def forInsert = name ~ body ~ userID ~ created ~ category ~ published ~ displayOrder ~ publishedBody <>
({ (name, body, userID, created, category, published, displayOrder, publishedBody) => Article(None, name, body, userID, created, category, published, displayOrder, publishedBody) },
{ u: Article => Some((u.name, u.body, u.userID, u.created, u.category, u.published, u.displayOrder, u.publishedBody)) }) returning id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment