Member-only story
Using the Diesel ORM for a Web App With Rocket
Adding database to a Rust powered framework

In one of my previous stories (see here), we have looked at an example of implementing a small web app by using the Rocket framework.
This web app did host the assets of a client app and provided a small API. Now, we are going to extend this by adding a database (PostgreSQL) together with the ORM named Diesel. Moreover, we will look into how to bundle this all together as a shareable web app by means of docker-compose.
General goal:
Let us summarize here what parts of the application we are planning to add. Remember, so far our application provides an endpoint that allows computing the convex hull of a given set of points.
Let us add the following things:
- allow saving a result from the above-mentioned endpoint
- allow to
GET
all results in order to list them at the UI - allow to
DELETE
results - allow to
UPDATE
a display name of a result
Setup
Of course, a useful thing when developing this is to have a PostgreSQL DB running in the background. You don’t need to install any locally on your system but instead just use a configured docker…