Created
July 30, 2014 06:04
-
-
Save SlevinBE/dadf964efb99dd634cb2 to your computer and use it in GitHub Desktop.
Slick BlogPostModel with optionally loaded author
This file contains 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
object BlogPostModel { | |
case class BlogPost ( | |
id: Option[Long] = None, | |
title: String, | |
author_id: Long, | |
postedDate: LocalDate, | |
summary: String, | |
content: String, | |
published: Boolean) { | |
var author: Option[User] = None | |
} | |
class BlogPosts(tag: Tag) extends Table[BlogPost](tag, "blog_post") { | |
def id = column[Long]("id", O.PrimaryKey, O.AutoInc) | |
def title = column[String]("title") | |
def author_id = column[Long]("author_id") | |
def postedDate = column[LocalDate]("date_posted") | |
def summary = column[String]("summary") | |
def content = column[String]("content") | |
def published = column[Boolean]("published") | |
def * = (id.?, title, author_id, postedDate, summary, content, published) <> (BlogPost.tupled, BlogPost.unapply) | |
} | |
val blogPosts = TableQuery[BlogPosts] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment