January 2019
Intermediate to advanced
520 pages
14h 32m
English
diesel creates a schema file that contains macro calls that generate a DSL language to use in the sources of your crate. A schema of tables that have relations to each other need extra declarations. Let's explore a generated schema in the src/schema.rs file to see how it differs from the simple schema we created earlier in this chapter.
The first table is users. It has the same columns we declared in the SQL file:
table! { users (id) { id -> Int4, email -> Text, }}
The table! macro will be expanded during compilation to some type and trait implementations that you can see with the following command:
cargo rustc -- -Z unstable-options --pretty=expanded
This command prints all expanded macros to a Terminal.
The diesel tool has also generated ...
Read now
Unlock full access