PostgreSQL JSONB columns are quite handy, there many times that I use them actually. I usually employ JSONB for (meta)data that even if they get lost, we are fine, we just need to do more manual work.
The usual cases include:
* caching data
* shortening relations, so instead of going table1 -> table2 -> table3 -> table4, you can store the table4 id inside table1 jsonb meta column to shorten the path (and vice versa)
* metadata that we want to store, but don’t deserve a dedicated column.
Working lately in Rust, I was trying to figure out how can I use a JSONB column with diesel. It turns out that it’s not that difficult actually!
In this tutorial, we are going to create a REST API in Rust with Actix web 2.0 and Diesel. We will be using Postgres as our database.
Today I want to show how to build a simple microservice. We will use Actix, Tokio-Postgress, and other libraries. We will use Postgress as our source of truth and we will run it in docker (for development sake). We also will use Barrel + some customs migration structure I created. The code will be all async and non-blocking IO. I hope you have fun, let’s get started.
View all tags