Tito
Tito is a powerful, flexible database layer built on top of TiKV, providing robust indexing strategies, relationship modeling, and transaction management capabilities for Rust applications.
Features
- Powerful Indexing Strategies: Define custom indexes with conditional logic for efficient querying
- Relationship Modeling: Create and manage embedded relationships between data models
- Transaction Management: Full ACID-compliant transaction support
- Type Safety: Leverages Rust's type system for safety and performance
- Flexible Query API: Query data using multiple strategies based on your application needs
Installation
Add Tito to your project:
[]
= "0.1.0"
Quick Start
Setting up a Connection
let tikv_client = connect.await?;
// Initialize config
let configs = TitoConfigs ;
// Create transaction manager
let tx_manager = new;
Creating a Model
// Create model
let user_model = new;
Basic CRUD Operations
// Create a user
let user_id = new_v4.to_string;
let user = User ;
// Create user with transaction
let saved_user = tx_manager
.transaction
.await?;
// Find user
let found_user = user_model.find_by_id.await?;
// Update user
let updated_user = User ;
tx_manager
.transaction
.await?;
// Delete user
tx_manager
.transaction
.await?;
Advanced Features
Conditional Indexing
Tito lets you conditionally index data based on business rules:
TitoIndexConfig
Relationship Modeling
Define relationships between models and fetch related data efficiently:
// Post model with references to multiple tags
// Fetch a post with all its related tags
let post_with_tags = post_model
.find_by_id // Include tags relationship
.await?;
Query by Index
Efficiently query data using custom indexes:
// Find posts by tag
let posts = post_model
.find_by_index
.await?;
Examples
For more detailed examples, check out the examples directory:
crud.rs- Basic CRUD operationsblog.rs- More complex example with relationships and various indexing strategies
Requirements
- Rust 2021 edition or later
- TiKV server running (local or remote)
License
This project is licensed under the Apache License, Version 2.0.