| Crates.io | solidb-client |
| lib.rs | solidb-client |
| version | 0.5.1 |
| created_at | 2026-01-19 14:31:16.295983+00 |
| updated_at | 2026-01-19 14:45:32.234012+00 |
| description | Official Rust client for SoliDB database |
| homepage | |
| repository | https://github.com/solisoft/solidb |
| max_upload_size | |
| id | 2054712 |
| size | 59,981 |
Official Rust client library for SoliDB, a lightweight, high-performance multi-document database.
Add to your Cargo.toml:
[dependencies]
solidb-client = "0.5.0"
tokio = { version = "1", features = ["full"] }
use solidb_client::{SoliDBClient, SoliDBClientBuilder};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), solidb_client::DriverError> {
// Connect to server
let mut client = SoliDBClient::connect("localhost:6745").await?;
// Authenticate (optional - depends on server config)
client.auth("mydb", "admin", "password").await?;
// Ping server
let version = client.ping().await?;
println!("Server version: {}", version);
// Create a database
client.create_database("mydb").await?;
// Create a collection
client.create_collection("mydb", "users", None).await?;
// Insert a document
let doc = client.insert("mydb", "users", None, json!({
"name": "Alice",
"age": 30,
"email": "alice@example.com"
})).await?;
println!("Inserted: {:?}", doc);
// Query documents with SDBQL
let users = client.query(
"mydb",
"FOR u IN users FILTER u.age > 25 RETURN u",
None
).await?;
println!("Users older than 25: {:?}", users);
Ok(())
}
For more control over connection setup:
let client = SoliDBClientBuilder::new("localhost:6745")
.auth("mydb", "admin", "password")
.timeout_ms(5000)
.build()
.await?;
SoliDBClient::connect(addr) - Connect to a serverclient.ping() - Check server connectivityclient.auth(database, username, password) - Authenticateclient.list_databases() - List all databasesclient.create_database(name) - Create a databaseclient.delete_database(name) - Delete a databaseclient.list_collections(database) - List collectionsclient.create_collection(database, name, collection_type) - Create a collectionclient.delete_collection(database, name) - Delete a collectionclient.collection_stats(database, collection) - Get collection statisticsclient.get(database, collection, key) - Get a document by keyclient.insert(database, collection, key, document) - Insert a documentclient.update(database, collection, key, document, merge) - Update a documentclient.delete(database, collection, key) - Delete a documentclient.list(database, collection, limit, offset) - List documents with pagination// Simple query
let results = client.query("mydb", "FOR u IN users RETURN u", None).await?;
// With bind variables
let mut bind_vars = std::collections::HashMap::new();
bind_vars.insert("min_age".to_string(), json!(25));
let results = client.query(
"mydb",
"FOR u IN users FILTER u.age > @min_age RETURN u",
Some(bind_vars)
).await?;
// Explain query plan
let plan = client.explain("mydb", "FOR u IN users RETURN u", None).await?;
client.create_index(database, collection, name, fields, unique, sparse) - Create an indexclient.delete_index(database, collection, name) - Delete an indexclient.list_indexes(database, collection) - List indexes// Begin a transaction
let tx_id = client.begin_transaction("mydb", None).await?;
// All operations within the transaction use the same connection
let _ = client.insert("mydb", "users", None, json!({"name": "Bob"})).await?;
// Commit
client.commit().await?;
// Or rollback
// client.rollback().await?;
// Batch multiple commands
let commands = vec![
solidb_client::Command::Insert { database: "mydb".to_string(), collection: "users".to_string(), key: None, document: json!({"name": "Carla"}) },
solidb_client::Command::Insert { database: "mydb".to_string(), collection: "users".to_string(), key: None, document: json!({"name": "David"}) },
];
let responses = client.batch(commands).await?;
// Bulk insert documents
let count = client.bulk_insert(
"mydb",
"users",
vec![
json!({"name": "Eve"}),
json!({"name": "Frank"}),
json!({"name": "Grace"}),
]
).await?;
println!("Inserted {} documents", count);
use solidb_client::DriverError;
match client.get("mydb", "users", "nonexistent").await {
Ok(doc) => println!("Found: {:?}", doc),
Err(DriverError::DatabaseError(msg)) => println!("Database error: {}", msg),
Err(DriverError::ConnectionError(msg)) => println!("Connection error: {}", msg),
Err(e) => println!("Other error: {}", e),
}
Currently no feature flags. The client is designed to be lightweight with minimal dependencies.
| Client Version | SoliDB Server Version |
|---|---|
| 0.5.0 | 0.5.0+ |
MIT License - see LICENSE file.
Contributions are welcome! Please see the main SoliDB repository for guidelines.