Name: essential-slick-code
Owner: Underscore
Description: Source Code for the examples in Essential Slick
Created: 2015-02-10 10:23:37.0
Updated: 2018-05-08 22:23:32.0
Pushed: 2018-03-07 07:52:41.0
Homepage: null
Size: 1294
Language: Scala
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Essential Slick provides a compact, no-nonsense guide to everything you need to know to use Slick in a commercial setting:
To find out more about the book and download the preview chapters, see Underscore.io.
If you're looking for the example code for Slick 2.1, use the 2.1 branch.
The code is organised as a folder for each chapter. Each folder contains an SBT project.
Each file is either the examples from the book, or the scaffolding for the exercises.
These projects contain a single source file, main.scala. Use the SBT run
or ~run
command.
For example:
chapter-01
sbt.sh
n
o] Running Example
ting database table
rting test data
cting all messages:
age(Dave,Hello, HAL. Do you read me, HAL?,1)
age(HAL,Affirmative, Dave. I read you.,2)
age(Dave,Open the pod bay doors, HAL.,3)
age(HAL,I'm sorry, Dave. I'm afraid I can't do that.,4)
cting only messages from HAL:
age(HAL,Affirmative, Dave. I read you.,2)
age(HAL,I'm sorry, Dave. I'm afraid I can't do that.,4)
cess] Total time: 5 s, completed 06/05/2015 2:22:22 PM
Chapter 5 contains several applications. Using the SBT run
command will prompt you for the file to run.
Alternatively, use runMain
or ~runMail
and supply the name of the class to run a particular example:
chapter-05
sbt.sh
unMain StructureExample
The examples are:
StructureExample
in structure.scala - an illustration of separating schema and profile.HListExampleApp
in hlists.scala - the HList example from the book.NestedCaseClassExampleApp
in nested_case_class.scala - is the exercise on custom case class mapping.NullExample
in nulls.scala - where the User
table has an optional email
field.PKExample
in primary_keys.scala - the User.id
becomes an Option[Long]
, and the OccupantTable
is added.ForeignKeyExample
in foreign_keys.scala - where MessageTable
has a foreign key to the UserTable
.ValueClassesExample
in value_classes.scala - introduces types for primary keys, as MessagePK
and UserPk
.SumTypesExample
in sum_types.scala - the message Flag
ing example from the book.CustomBooleanExample
in custom_boolean.scala - is the “Custom Boolean” exercise code.This project contains a chat_schema.scala file that defines the schema for the chapter.
It also defines the method populate
which inserts our standard cast, rooms, and messages into the database.
The schema is re-used in the following examples:
JoinsExample
in joins.scala - runs through a variety of joins using the sample data in chat_schema.scala.AggregatesExample
in aggregates.scala - various group by and aggregation examples..joins.scala contains much that is commented out. Remove the comments from around the code you are interest in to run it.
This project contains the following examples:
SelectExample
in select.scala - gives examples with the sql
interpolator.UpdateExample
in updates.scala - gives examples with the sqlu
interpolator.TsqlExample
in tsql.scala - examples using typed plain queries.