mool 0.2.0

A source-first Rust database toolkit for typed SQL queries, migrations, and model metadata
Documentation
use mool as db;
use mool::Model;

#[derive(Debug, Clone, db::Model)]
#[table(name = "posts")]
struct Post {
    id: i64,
    title: String,
    published: bool,
}

#[derive(Debug, Clone, db::Filterable)]
#[filter(model = Post)]
struct PostFilter {
    #[filter(op = "eq")]
    published: Option<bool>,
    #[filter(op = "ilike", column = "title")]
    q: Option<String>,
    #[filter(op = "in", column = "id")]
    ids: Vec<i64>,
}

fn main() -> Result<(), db::QueryError> {
    let posts = Post::table();
    let filter = PostFilter {
        published: Some(true),
        q: Some("%mool%".to_string()),
        ids: vec![1, 2],
    };
    let plan = db::from(&posts)
        .filter_with(&filter)
        .all::<Post>()
        .plan(db::queries::Dialect::Postgres)?;

    assert!(plan.sql.contains("ILIKE"));
    assert_eq!(plan.total_bind_count, 4);
    Ok(())
}