We have used the Persistent library and SQL expressions using the Database.Persist.SQL module. We have used the generated types for each field in the filter, insert, and update expressions. But the complexity of the query can increase rapidly. Of course, there is a way to do a plain SQL query with the persistent library. Here, in this recipe, we will be using the Esqueleto library to do complex queries such as joins.
In this recipe, we will write a complex SQL query that is type-safe and easy to write. Being type-safe is good, because we will catch any major issues earlier on!