I am trying to use diesel for a project and I would like to have a "filterable" type. The idea is that you can go to /api/foo?id=10&bar=11 and it would return a struct Foo:
struct Foo {
id: Option<i64>,
bar: Option<i64>,
name: Option<String>,
}
Such as:
Foo {
id: Some(10),
bar: Some(11),
name: None,
}
I've been scouring the internet for a way to filter by the fields that exist, but I am unable to find a solution that works. I was initially using the mysql driver and constructing sql queries with proc macros, but diesel is a lot nicer to work with and I was wondering if there was a way to get the same behaviour I had with the mysql driver with diesel.