Expand description
ScrivaDB Rust client — async gRPC wrapper over proto/scriva.proto.
All methods are async and require a Tokio runtime.
§Quick start
use scriva::{ScrivaDB, FilterInput, FilterOp, FindOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut db = ScrivaDB::connect("localhost", 5433, "dev-key").await?;
db.create_collection("users").await?;
let id = db.insert("users", serde_json::json!({"name": "Alice", "age": 30})).await?;
let record = db.find_by_id("users", id).await?;
println!("{:?}", record);
let admins = db.find("users", FindOptions {
filter: Some(FilterInput::field("role", FilterOp::Eq, "admin")),
..Default::default()
}).await?;
println!("{} admins", admins.len());
db.drop_collection("users").await?;
Ok(())
}Structs§
- Aggregate
Group - One group’s result from
ScrivaDB::aggregate. - Aggregate
Options - Options for
ScrivaDB::aggregate. - CasResult
- Result of a compare-and-swap update (
ScrivaDB::update_if_rev). - Collection
Stats - Collection statistics returned by
stats. - Find
Options - Options for the
findmethods. - OrderBy
- One sort key and its direction, for the multi-field ordering of a
find. - Record
- A record returned by the server.
- ScrivaDB
- Async gRPC client for ScrivaDB.
- Update
Result - Result of a keyed update (
ScrivaDB::update_by_key). - Watch
Event - A change event delivered by the
watchstream.
Enums§
- Aggregate
Op - A numeric aggregation to compute per group over a request’s
field. - Filter
Input - A composable filter for
findandwatchqueries. - Filter
Op - Comparison operator for a
FilterInput::Field. - Scriva
DbError - Errors returned by ScrivaDB RPC methods.
- WatchOp
- The operation type in a
WatchEvent.
Type Aliases§
- Error
- Transport / setup errors from
ScrivaDB::connect,ScrivaDB::connect_tlsand the file-writing snapshot helper. RPC methods returnScrivaDbError.