- Rust 100%
| cli | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| readme.md | ||
| todo.md | ||
surrealdb-client
An lightwight, easy-to-use client for surrealdb databases.
License
This project is licensed under AGPL-3.0-or-later. For more information see the LICENSE file, or alternative online under https://www.gnu.org/licenses/.
Usage
use surrealdb_client::{
Connection,
auth,
url::Url,
QueryResult,
JsonValue,
DbInfo,
};
let mut conn = Connection::connect(Url::parse("wss://your.domain.tld")).await?;
let token = conn.signin(auth::Root {
user: "root",
pass: "toor",
}).await?;
conn.authenticate(token).await?;
// Query:
let info: Vec<QueryResult<JsonValue>> = conn.query_raw("INFO FOR DB;").await?;
// Or if you have the `info-for` feature active:
let info: DbInfo = conn.info_for_db().await?;
Note on "raw" methods and functions
While there are plenty of "raw" methods (usually using the suffix _raw), these are
always considered unstable for now, since it is not determined if these will continue
to work this way or if it will be redesigned using serde_json's own raw_value feature.
Note on rustls
This crate does NOT provide any default for the crypto provider setup. This means you would need to depend on the rustls crate yourself and choose either the aws-lc-rs or ring features.
Debugging
The debugging interface is currently WIP; however, the crate supports minimal request-response and error logging, configureable via features:
stderr-log: Prints everything just to stderr viaeprintln!; intended for quick-and-dirty debugging.tracing: Prints everything using tracing's logging macros (debug!and so on). Note that real tracing isn't supported yet.log: Prints everything using log's logging macros (debug!and so on).
All three can be activated at the same time if you so desire.