#diesel #filter #query

into_query

Convert option structs into filters for use with diesel

5 releases

0.2.4 Apr 2, 2022
0.2.3 Feb 24, 2021
0.2.1 Feb 24, 2021
0.2.0 Dec 3, 2020
0.1.0 Dec 3, 2020

#2944 in Database interfaces

MIT license

4KB

into_query

Usage

#[derive(IntoQuery)]
#[table_name = "whateverlol"]
pub struct Filter {
    foo: Option<String>,
    bar: Option<Vec<i32>>,
    baz: Option<Vec<u8>>,
}

Features

mysql, postgres, sqlite: Set the backend to be used by the query builder (default: mysql)

Attributes

table_name: required

schema::<this>::dsl::<this>

schema_prefix: optional (default: crate)

<this>::schema::<table_name>::dsl

For example, if your project was structured as

src
│   main.rs
└───db
    └───schema.rs

and your table was "cats"

#[derive(IntoQuery)]
#[table_name = "cats"]
#[schema_prefix = "crate::db"]
struct CatOptions {
    ..
}

Dependencies

~3–7MB
~154K SLoC