for rust backend devs: try out clorinde (github)!
it's a maintained fork of cornucopia, and the main premise as opposed to e.g. sqlx is that you have your queries in separate .sql files that the tool then generates bindings for!
example: if you have this in queries/users.sql:
--! get_followers_by_user_id
select f.follow_state,
f.follower_id,
u.user_display_name
from follower f
left join user u on f.follower_id = u.user_id
where f.followee_id = :id
(the --! part is important! it sets the query name, and is also used for specifying nullable result fields/args)
clorinde will generate a new crate in your project with a wrapper over every query that you can use e.g. like this:
// ...
let followers = users::get_followers_by_user_id()
.bind(&pg_client, user_id)
.all().await;
for fw in follower {
println!("{:?}", fw);
}
hehe i use hashtags now:
#rust #backend #sqlx