Introducing the Slick framework
Scala Language Integrated Connection Kit (Slick) is a Scala modern framework, which allows working with data using abstractions that are very similar to Scala collections. You can write database queries in both SQL and Scala code. Writing Scala code instead of SQL is better, because we leverage the compiler, and hence, this approach is less error-prone. Also, it becomes easier to maintain the code, since the compiler will help you by pointing out where the code breaks, if it happens.
Slick is a Functional Relational Mapping (FRM) library. Those of you who come from a Java background, and are familiar with Object Relational Mapping (ORM) frameworks such as Hibernate, will see that Slick has similar concepts. Basically, you create a Scala class, which will explicitly map to a relational table. Slick FRM ideas are inspired by Microsoft's LINQ framework.
Slick is reactive by design, and works in an asynchronous non-blocking IO model. Using Slick you have the following advantages:
- • Resilience: A common issue is that a heavy load on the DB and application creates more threads, and makes the situation worse. Slick can fix this problem, because it queues database operations in the DB.
- • Efficient Resources utilization: Slick can be tuned for parallelism in terms of the number of active jobs and suspended database sessions. Slick also has a clean demarcation between I/O and CPU-intensive code.