#object-oriented #query-builder #columns

bin+lib qoo

query builder library. Query Object Oriented.

4 releases

0.1.3 Jan 8, 2022
0.1.2 Jan 6, 2022
0.1.1 Jan 1, 2022
0.1.0 Jan 1, 2022

#16 in #columns

MIT license

12KB
232 lines

qoo

Latest Version Docs

Query Object Oriented.
Pronunciation is Kuu.

demo

use qoo::prelude::*;

fn main() {
    let select_query =
        SelectBuilder::select(&["col0", "col1"])
            .columns(&["col2", "col3"])
            .from("table1")
            .wheres("id >= 100");
    assert_eq!(
        select_query.to_sql(),
        "select col0, col1, col2, col3 from table1 where id >= 100"
    );

    let insert_query =
        InsertBuilder::insert("test1")
            .columns(&["col0", "col1"])
            .value("'xxx'")
            .value("'yyy'");
    assert_eq!(
        insert_query.to_sql(),
        "insert into test1 (col0, col1) values ('xxx', 'yyy')"
    );

    let update_query =
        UpdateBuilder::update("test1")
            .set("col1='aaa'")
            .set("col2='bbb'")
            .wheres("id >= 11");
    assert_eq!(
        update_query.to_sql(),
        "update test1 set col1='aaa', col2='bbb' where id >= 11"
    );

    let delete_query =
        DeleteBuilder::delete()
            .from("test1")
            .wheres("id >= 100");
    assert_eq!(
        delete_query.to_sql(),
        "delete from test1 where id >= 100"
    );
}


inspired by

No runtime deps