The overview on the book page states that this is a book aimed at intermediate Scala developers who wish to quickly become productive with the Slick database library. Having read the book, and before delving into the details, I can confidently say that it provides an excellent guide to working with Slick.
The book is structured as follows:
- chapters 1 to 3 provide a guide on basic types, inserts, deletes, and selects
- chapter 4 talks about data modeling
- chapters 5 and 6 describe ways to combine queries as well as joins and aggregates
- chapter 7 shows how to execute plain SQL
Chapters 1 through to 3 provide a guide to basic types, inserts, deletes and selects. While much of this is covered in Slick documentation, the book does a better job of explaining how to create queries and execute them whether with Future or not. I, especially, appreciated description of
DBIO[R, S, E] type in chapter 2. In chapter 3 the book shows inserts and updates. Possibly the most interesting point here the description of driver capabilities.
Chapter 4 provides an excellent overview of various Slick combinators, ie
flatMap. Not forgotten are
DBIO.failed which are often searched for when starting with Slick. The overview of logging and transactions in this chapters are a good start. However, there is no mention of
Chapter 5, for me, was most interesting and useful. Here the authors show how to use custom types with Slick. Up to this point, all of the queries were executed against database-like data (rows of primitive types). In this chapter we also discover how to work with Shapeless’ HLists, value classes, compound primary keys. This content is priceless.
The following chapter, 6, discusses the use of plain SQL with Slick. The coverage of the options is quite good. An example of updating a custom type is included as well as working with typed SQL expressions. For completeness it would have been good to see an example of with database specific types which Slick doesn’t understand. For example, PostgreSQL has
inet type values. Working with this type in Slick essentially requires plain SQL. This might also have served as a good motivating example for plain SQL.
The book doesn’t end with chapter 7. Several appendices cover the use of Slick with different database engines as well as Play! framework integration. The Play! integration section is a little thin. Furthermore, the example shows the use of
GlobalSettings which has been deprecated in Play! 2.4. I think an example with Play! 2.4 using injection would have been more useful in the long run.
It should be mentioned that every chapter contains exercises. The exercises are well structured and provide a great way to cement the material. The solutions to the exercises are in the appendix.
All in all, the few minor things should not overshadow the rest of the book. I would recommend this book to anyone starting with Slick.
PS Thanks to the people at Underscore.io for giving me a free copy of the book to review.