Crate unreql

Source
Expand description

§Unofficial RethinkDB Driver for Rust

Well documented and easy to use

§Import

use unreql::r;

§Connect

use unreql::{r, cmd::connect::Options};

let conn = r.connect(Options::new().db("marvel")).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

use futures::TryStreamExt;

let mut cur = r.table("users").run::<_, User>(&conn);
while let Ok(Some(user)) = cur.try_next().await {
  // do something with user
  dbg!(user);
}

§Update data

use unreql::{r, rjson};

r.table("users")
    .get(1)
    .update(rjson!({
        "name": "Jonh",
        "upd_count": r.row().g("upd_count").add(1),
    }))
    .run::<_, serde_json::Value>(&conn);

Re-exports§

pub use cmd::func::Func;
pub use types::DateTime;

Modules§

cmd
types

Macros§

func
rjson

Structs§

Connection
ServerInfo
Session
The connection object returned by r.connect()
r
The top-level ReQL namespace

Enums§

Availability
A server in the cluster is unavailable
Command
The query that will be sent to RethinkDB
Datum
Driver
An error has occurred within the driver
Error
The most generic error message in ReQL
Runtime
The parent class of all runtime errors

Type Aliases§

Result
Custom result returned by various ReQL commands