Skip to content

Instantly share code, notes, and snippets.

@SlevinBE
Created July 30, 2014 06:04
Show Gist options
  • Save SlevinBE/dadf964efb99dd634cb2 to your computer and use it in GitHub Desktop.
Save SlevinBE/dadf964efb99dd634cb2 to your computer and use it in GitHub Desktop.
Slick BlogPostModel with optionally loaded author
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