2 releases
0.1.1 | Mar 9, 2024 |
---|---|
0.1.0 | Jan 21, 2024 |
#7 in #rethink-db
83 downloads per month
Used in 2 crates
(via unreql)
17KB
485 lines
Unofficial RethinkDB Driver for Rust
Well documented and easy to use
Motivation
The official driver is difficult to support, awkward to use, and has little to no documentation or examples. Therefore, an attempt was made by me to remedy these shortcomings
Install
$ cargo add unreql
or
[dependencies]
unreql = "0.1.4"
Import
use unreql::r;
Connect
let conn = r.connect(()).await?;
Get data
Get by ID
let user: User = r.table("users").get(1).exec(&conn).await?;
Get all data
let users: Vec<User> = r.table("users").exec_to_vec(&conn).await?;
or
let mut cur = r.table("users").run(&conn);
let mut users: Vec<User> = vec![];
while let Ok(Some(user)) = cur.try_next().await? {
users.push(user);
}
Update data
Use a nested reql query
r.table("users")
.get(1)
.update(rjson!({
"name": "John",
"upd_count": r.row().g("upd_count").add(1),
}))
.run(&conn);
Dependencies
~2MB
~42K SLoC