gitdb-client-1.0.1 is not a library.
GitDB Rust Client
Official Rust client for GitDB - GitHub-backed NoSQL database.
Installation
Add this to your Cargo.toml
:
[]
= "1.0.0"
Quick Start
use GitDBClient;
use HashMap;
use json;
async
Features
- ✅ Zero-cost abstractions - High performance with minimal overhead
- ✅ Memory safety - Rust's ownership system prevents common bugs
- ✅ Async/await support - Non-blocking operations with tokio
- ✅ Type safety - Strong typing throughout the API
- ✅ Error handling - Comprehensive error handling with anyhow
- ✅ CRUD operations - Create, Read, Update, Delete documents
- ✅ Query support - MongoDB-style query operators
- ✅ GraphQL integration - Native GraphQL query support
- ✅ Batch operations - Insert, update, delete multiple documents
- ✅ Collection management - Create, list, delete collections
API Reference
Client Creation
// Basic client
let client = new;
// Client with custom URL
let client = with_url;
Health Check
// Check if server is healthy
client.health.await?;
Collection Management
// Create a collection
client.create_collection.await?;
// List all collections
let collections = client.list_collections.await?;
for collection in collections
// Delete a collection
client.delete_collection.await?;
Document Operations
Insert
let mut document = new;
document.insert;
document.insert;
let id = client.insert.await?;
Find
// Find all documents
let all_users = client.find.await?;
// Find with query
let mut query = new;
query.insert;
let older_users = client.find.await?;
// Find one document
let user = client.find_one.await?;
// Find by ID
let user = client.find_by_id.await?;
Update
let mut update = new;
update.insert;
update.insert;
client.update.await?;
Delete
// Delete by ID
client.delete.await?;
// Delete multiple documents
let mut query = new;
query.insert;
let deleted_count = client.delete_many.await?;
Batch Operations
// Insert multiple documents
let mut documents = Vec new;
for i in 1..=5
for doc in documents
// Update multiple documents
let mut query = new;
query.insert;
let mut update = new;
update.insert;
let updated_count = client.update_many.await?;
GraphQL Queries
// Simple GraphQL query
let query = r#"
query {
users {
id
name
age
}
}
"#;
let response = client.graphql_simple.await?;
if let Some = response.data
// GraphQL query with variables
let query = r#"
query GetUser($id: String!) {
user(id: $id) {
id
name
age
}
}
"#;
let mut variables = new;
variables.insert;
let response = client.graphql.await?;
Query Operators
The Rust client supports MongoDB-style query operators:
let mut query = new;
// Equal
query.insert;
// Greater than
query.insert;
// Greater than or equal
query.insert;
// Less than
query.insert;
// Less than or equal
query.insert;
// Not equal
query.insert;
// In array
query.insert;
// Not in array
query.insert;
// Regular expression
query.insert;
Error Handling
The client uses anyhow::Result
for error handling:
use Result;
async
Configuration
Environment Variables
You can configure the client using environment variables:
Custom HTTP Client
The client uses reqwest
with a 30-second timeout by default. You can customize this:
let client = with_url;
client.set_base_url;
Testing
Run the tests:
Examples
See the examples/
directory for more detailed examples:
- Basic usage
- Advanced queries
- GraphQL operations
- Error handling
- Batch operations
Dependencies
reqwest
- HTTP clienttokio
- Async runtimeserde
- Serialization/deserializationserde_json
- JSON handlinganyhow
- Error handling
License
MIT License - see LICENSE file for details.
Authors
- AFOT Team team@afot.com
- karthikeyanV2K karthikeyan@afot.com