Adding SQLX to our Data Access Layer
Before we cover how to handle SQLX in our data access layer, it makes sense to explain why we are using SQLX. In previous editions we covered diesel for the data access as this was an ORM for postgres and Rust. However, you get more flexibility by just writing SQL, and the nature of Rust structs that can be augmented by traits means that the results can simply yield structs that we can directly work with. Furthermore, SQLX does not require a complex schema setup where all the columns need to match exactly when declaring the schema, instead we just write the SQL queries and pass in the struct that we want returned in the query. However, if you feel passionately that you want to use Diesel, do not worry, we are going to structure the data access layer in such a way that you can keep adding different data access methods. By the end of this section, we will have a data access layer that supports the JSON file storage method that we are currently using...