-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
442747b
commit 60239e6
Showing
8 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// DO NOT EDIT! This file is auto-generated. | ||
// This file enables sbt-bloop to create bloop config files. | ||
|
||
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.0-RC1") | ||
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.0-RC1-105-118a551b") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package controllers | ||
|
||
import javax.inject._ | ||
|
||
import play.api.mvc._ | ||
import play.api.i18n._ | ||
import models.TaskListInMemoryModel | ||
import play.api.libs.json._ | ||
import models._ | ||
|
||
import play.api.db.slick.DatabaseConfigProvider | ||
import scala.concurrent.ExecutionContext | ||
import play.api.db.slick.HasDatabaseConfigProvider | ||
import slick.jdbc.JdbcProfile | ||
import slick.jdbc.PostgresProfile.api._ | ||
|
||
@Singleton | ||
class TaskList5 @Inject() (protected val dbConfigProvider: DatabaseConfigProvider, cc: ControllerComponents)(implicit ec: ExecutionContext) | ||
extends AbstractController(cc) with HasDatabaseConfigProvider[JdbcProfile] { | ||
|
||
def load = Action { implicit request => | ||
Ok(views.html.version4Main()) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package models | ||
|
||
object CodeGen extends App { | ||
slick.codegen.SourceCodeGenerator.run( | ||
"slick.jdbc.PostgresProfile", | ||
"org.postgresql.Driver", | ||
"jdbc:postgresql://localhost/tasklist?user=mlewis&password=password", | ||
"/home/mlewis/PlayVideos/play-videos/server/app/", | ||
"models", None, None, true, false | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package models | ||
// AUTO-GENERATED Slick data model | ||
/** Stand-alone Slick data model for immediate use */ | ||
object Tables extends { | ||
val profile = slick.jdbc.PostgresProfile | ||
} with Tables | ||
|
||
/** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */ | ||
trait Tables { | ||
val profile: slick.jdbc.JdbcProfile | ||
import profile.api._ | ||
import slick.model.ForeignKeyAction | ||
// NOTE: GetResult mappers for plain SQL are only generated for tables where Slick knows how to map the types of all columns. | ||
import slick.jdbc.{GetResult => GR} | ||
|
||
/** DDL for all tables. Call .create to execute. */ | ||
lazy val schema: profile.SchemaDescription = Items.schema ++ Users.schema | ||
@deprecated("Use .schema instead of .ddl", "3.0") | ||
def ddl = schema | ||
|
||
/** Entity class storing rows of table Items | ||
* @param itemId Database column item_id SqlType(serial), AutoInc, PrimaryKey | ||
* @param userId Database column user_id SqlType(int4), Default(None) | ||
* @param text Database column text SqlType(varchar), Length(2000,true), Default(None) */ | ||
case class ItemsRow(itemId: Int, userId: Option[Int] = None, text: Option[String] = None) | ||
/** GetResult implicit for fetching ItemsRow objects using plain SQL queries */ | ||
implicit def GetResultItemsRow(implicit e0: GR[Int], e1: GR[Option[Int]], e2: GR[Option[String]]): GR[ItemsRow] = GR{ | ||
prs => import prs._ | ||
ItemsRow.tupled((<<[Int], <<?[Int], <<?[String])) | ||
} | ||
/** Table description of table items. Objects of this class serve as prototypes for rows in queries. */ | ||
class Items(_tableTag: Tag) extends profile.api.Table[ItemsRow](_tableTag, "items") { | ||
def * = (itemId, userId, text) <> (ItemsRow.tupled, ItemsRow.unapply) | ||
/** Maps whole row to an option. Useful for outer joins. */ | ||
def ? = ((Rep.Some(itemId), userId, text)).shaped.<>({r=>import r._; _1.map(_=> ItemsRow.tupled((_1.get, _2, _3)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) | ||
|
||
/** Database column item_id SqlType(serial), AutoInc, PrimaryKey */ | ||
val itemId: Rep[Int] = column[Int]("item_id", O.AutoInc, O.PrimaryKey) | ||
/** Database column user_id SqlType(int4), Default(None) */ | ||
val userId: Rep[Option[Int]] = column[Option[Int]]("user_id", O.Default(None)) | ||
/** Database column text SqlType(varchar), Length(2000,true), Default(None) */ | ||
val text: Rep[Option[String]] = column[Option[String]]("text", O.Length(2000,varying=true), O.Default(None)) | ||
|
||
/** Foreign key referencing Users (database name items_user_id_fkey) */ | ||
lazy val usersFk = foreignKey("items_user_id_fkey", userId, Users)(r => Rep.Some(r.id), onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.Cascade) | ||
} | ||
/** Collection-like TableQuery object for table Items */ | ||
lazy val Items = new TableQuery(tag => new Items(tag)) | ||
|
||
/** Entity class storing rows of table Users | ||
* @param id Database column id SqlType(serial), AutoInc, PrimaryKey | ||
* @param username Database column username SqlType(varchar), Length(20,true) | ||
* @param password Database column password SqlType(varchar), Length(200,true) */ | ||
case class UsersRow(id: Int, username: String, password: String) | ||
/** GetResult implicit for fetching UsersRow objects using plain SQL queries */ | ||
implicit def GetResultUsersRow(implicit e0: GR[Int], e1: GR[String]): GR[UsersRow] = GR{ | ||
prs => import prs._ | ||
UsersRow.tupled((<<[Int], <<[String], <<[String])) | ||
} | ||
/** Table description of table users. Objects of this class serve as prototypes for rows in queries. */ | ||
class Users(_tableTag: Tag) extends profile.api.Table[UsersRow](_tableTag, "users") { | ||
def * = (id, username, password) <> (UsersRow.tupled, UsersRow.unapply) | ||
/** Maps whole row to an option. Useful for outer joins. */ | ||
def ? = ((Rep.Some(id), Rep.Some(username), Rep.Some(password))).shaped.<>({r=>import r._; _1.map(_=> UsersRow.tupled((_1.get, _2.get, _3.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) | ||
|
||
/** Database column id SqlType(serial), AutoInc, PrimaryKey */ | ||
val id: Rep[Int] = column[Int]("id", O.AutoInc, O.PrimaryKey) | ||
/** Database column username SqlType(varchar), Length(20,true) */ | ||
val username: Rep[String] = column[String]("username", O.Length(20,varying=true)) | ||
/** Database column password SqlType(varchar), Length(200,true) */ | ||
val password: Rep[String] = column[String]("password", O.Length(200,varying=true)) | ||
} | ||
/** Collection-like TableQuery object for table Users */ | ||
lazy val Users = new TableQuery(tag => new Users(tag)) | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE USER mlewis WITH PASSWORD 'password'; | ||
|
||
CREATE DATABASE tasklist WITH OWNER=mlewis; |