The major advantage of using HugSQL is that it allows us to write the SQL queries in separate files instead of having to embed strings in our code. This has a number of advantages, such as allowing us to use SQL tools to edit the queries.
Getting Things Done with HugSQL
HugSQL provides a flexible DSL for generating the functions for running SQL queries. We’ll start by seeing how we can define a single query in a file and then create a function from it using the def-db-fns macro. Let’s place the query in the resources/find_user.sql file in our project.
|||-- :name add-user! :! :n|
|||-- :doc adds a new user|
|||INSERT INTO users|
|||VALUES (:id, :pass)|
HugSQL uses specially formatted SQL ...