How it works...
Working with diesel-rs requires a good understanding of how it works internally to achieve the desired results. Check out the previous recipe (Using an ORM to save data to a database) for some details on the basics. In this recipe, we are diving straight into the more advanced stuff.
After some basic setup in step 1, step 2 creates a new handler that fetches all bookmarks added on a particular day and returns the date as a Julian date (https://en.wikipedia.org/wiki/Julian_day). The calculation is done using one of SQLite's few scalar functions: juliandate() (https://www.sqlite.org/lang_datefunc.html). So, how did we get the function into Rust? Step 4 shows the diesel-rs way: by using a sql_function! macro (https://docs.diesel.rs/diesel/macro.sql_function.html ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access