Appearance
DB Context
A DB Context will store the ModelContext's data into a relational database. The Slick library is used to map to the underlying DB.
The quickest way to make a ModelContext for the DB is to use the Vasat macro annotation @DBAuto
scala
@JSONModel // Makes the mode have a JSON representation
case class Article(
name:String,
category:String,
author:Ref[Author],
datePosted:Date,
active:Boolean
) extends PublicACL
@DBAuto // generates the ModelContext
class ArticleRepo extends DBContext[Article,SlickBaseTable]
Internally this macro will define the slick Table
as well as mappings to and from the Model definition to the slick table.
Behind the scenes the macro populates a DBModelContext
and a SlickSearchable
which allow for both search and read/write/delete.
Without the macro, a ModelContext mapping to the DB can be achived, but will require many lines of code and a knowledge of Slick.