🎯 Hesoyam ORM
Just another one ORM for for Postgres and Clickhouse. If you found it useful please give us a ⭐ :)
Installation
Cargo.toml
:
[]
= "0.1.4"
Examples
Let's custom model at first. If we won't pass table_name as macro argument default will be generated. It assumed that tables already created in db.
model.rs
be like:
Now we should provide database config to start work:
let pg_conf = new.
host.
user.
password.
port.
database;
let ch_conf = new.
schema.
hostname.
port;
let mut cm = new.
add_client?.
add_client?;
Insert one and multiple entries
use *
// insert one entry
let name = String from;
let age = 20;
save.exec?;
// do the same with multiple users
let users = vec!;
users.save.exec?;
Select entries
Pay attention that From
trait is implemented by #[model]
macro:
let res = select.filter.exec?;
for r in res
Raw queries
Also there are #[query_result]
macro to simplify converting raw query result to struct:
let raw_query = r#"
select
entity_id,
max(high) as max_high
from market_quote
group by entity_id
order by entity_id;
"#;
let res = cm.
get_client?.
query?;
for row in res
For more (update/delete) please go to examples 🙂