Defines the DBAction default behaviour
DB Action, decoupled from Application
DB Action, decoupled from Application
Useful for tests, see TestableDBActionTest.scala
Wrapped request with added db-specific information.
Wrapped request with added db-specific information.
See the slick package object for implicit functions to extract this information.
Value class wrapper for optionally supplied implicit Applications.
This profile makes it easier to use the cake pattern with Slick
This profile makes it easier to use the cake pattern with Slick
class DAO(override val profile: ExtendedProfile) extends CatComponent with Profile trait CatComponent { this: Profile => //<- step 1: you must add this "self-type" import profile.simple._ //<- step 2: then import the correct Table, ... from the profile object Cats extends Table[Cat]("CAT") { ... } } object current { val dao = new DAO(DB.driver(play.api.Play.current)) }
See the sample application for another example
Use the DBAction when you want to use the default settings in your controller.
Use the DBAction when you want to use the default settings in your controller.
def index = DBAction{ implicit rs => Ok(MyStuff.list()) }
By default it uses the database named by default in the configuration in all modes (Prod, Dev) except in test, where it uses test.
It is possible to define a maximum amount queries per request that can be handled at a given point to avoid overloading the application (user gets the error page instead of seeing a slow app).
The maximum amount of per requests is read from: db.<db-name>.maxQueriesPerRequest
If you need to override the default behavior, create a new object with the DefaultDBAction trait.
class AnotherDBAction(myApp: Application, myErrorPage: Result) extends DefaultDBAction { override lazy val app = myApp override val errorPage = myErrorPage }
Use the MaybeApplication wrapper to avoid multiple overloaded methods with defaults.