I started learning how to use Diesel to query a database. I have a table that looks something like the structure below (this is just a toy project that will help me understand how diesel works).
#[derive(Queryable, Insertable)]
#[table_name="posts"]
struct Post {
id: String,
title: String,
body: String,
published: bool
}
Executing queries that are fully defined at compile time is quite simple, for example
posts.select(id, title).order(title.desc());
I donβt understand how to build a query depending on some runtime parameters without returning to SQL. For example, JSONAPI allows you to dynamically select fields and sort them based on query parameters. How can I do this in Diesel?
source
share