Mongoose-style ORM for ToonStore - Type-safe, schemaless models with validation, queries, and relationships across Rust, Node.js, Python, Go, and PHP.
TORM is an Object-Relational Mapper (ORM) for ToonStore, inspired by Mongoose (MongoDB's ORM). Just as MongoDB is schemaless but Mongoose provides application-level schemas, ToonStore is schemaless but TORM provides type-safe models.
- β Schemaless Storage - ToonStore stores data in efficient TOON format without rigid schemas
- β Application-Level Schemas - Type-safe models with validation in your code
- β Type Safety - Rust derive macros & type checking across all languages
- β Validation - Built-in validators (email, URL, length, range, pattern)
- β Query Builder - Fluent API for filtering, sorting, and pagination
- β Relationships - Reference other models like traditional ORMs
- β Migrations - Track and manage schema changes over time
- β TORM Studio - Visual database management (like Drizzle Studio)
- β Multi-Language - Rust, Node.js, Python, Go, PHP support via REST API
TOON (Token-Oriented Object Notation) is a compact, human-readable data format designed for the age of AI and LLMs. ToonStore uses TOON format for efficient data storage.
- π€ LLM-Optimized: 74% accuracy vs JSON's 70% in LLM comprehension benchmarks
- π° Cost-Efficient: ~40-60% fewer tokens = lower API costs for AI applications
- π Schema-Aware: Explicit
[N]lengths and{fields}help LLMs parse reliably - π JSON-Compatible: Lossless round-trips with same objects/arrays/primitives
- ποΈ Human-Readable: YAML-like readability with CSV-style compactness
JSON (22,250 tokens):
{
"users": [
{"id": "1", "name": "Alice", "email": "alice@example.com", "age": 30},
{"id": "2", "name": "Bob", "email": "bob@example.com", "age": 25}
]
}TOON (9,120 tokens - 59% reduction):
users[2]{id,name,email,age}:
1,Alice,alice@example.com,30
2,Bob,bob@example.com,25
Learn More: TOON Format Repository
While schemaless databases offer flexibility, applications need:
- Type safety to prevent bugs
- Validation to ensure data quality
- Relationships to model real-world data
- Consistent APIs across languages
Like MongoDB + Mongoose, TORM combines the best of both:
| Layer | Technology | Purpose |
|---|---|---|
| Storage | ToonStore (schemaless TOON format) | Fast, flexible, token-efficient storage |
| Application | TORM (schemas) | Type safety, validation, relationships |
Benefits:
- π Performance - ToonStore's speed (5.28M ops/sec)
- π‘οΈ Safety - Type checking and validation at application level
- π Flexibility - Add fields without database migrations
- π° Efficiency - TOON format saves ~40% tokens (perfect for AI/LLM apps)
- πͺ Power - Rich query APIs and relationship support
Rust library for defining models and interacting with ToonStore
REST API server for multi-language support (Node.js, Python, Go, PHP)
Proc macros for deriving Model trait
use torm::{Model, TormDb};
use serde::{Deserialize, Serialize};
#[derive(Model, Serialize, Deserialize, Debug)]
struct User {
#[id]
id: String,
name: String,
email: String,
age: Option<u32>,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to ToonStore
let db = TormDb::connect("redis://localhost:6379").await?;
// Create user
let user = User {
id: "user:1".into(),
name: "John Doe".into(),
email: "john@example.com".into(),
age: Some(30),
};
user.save(&db).await?;
// Find user
let found = User::find_by_id(&db, "user:1").await?;
println!("Found: {:?}", found);
Ok(())
}TORM Server provides REST API for any language:
const { TormClient, Model } = require('@toonstore/torm');
const torm = new TormClient('http://localhost:3001');
const User = Model.define('User', { /* schema */ });
await user.save();from toonstore import TormClient, Model
torm = TormClient('http://localhost:3001')
class User(Model):
name: str
email: str
await user.save()import "github.com/toonstore/torm-go"
type User struct { /* fields */ }
client.Model("users").Create(&user)- Quick Reference - URLs, commands, and common operations
- Getting Started Guide - Complete beginner's tutorial with examples
- FAQ - All Your Questions Answered - Data format, persistence, TOON format, Studio access, etc.
- Models & Schemas - Define type-safe models (Coming Soon)
- Validation - Built-in and custom validators (Coming Soon)
- Queries - Filtering, sorting, pagination (Coming Soon)
- Relationships - Model relationships (Coming Soon)
- Migrations - Track schema changes and transform data
- TORM Studio - Visual database management (like Drizzle Studio)
- CLI Reference - Command-line tools (Coming Soon)
- Rust API - Rust library documentation (Coming Soon)
- REST API - HTTP API for all languages (Coming Soon)
- Node.js SDK - JavaScript/TypeScript
- Python SDK - Python
- Go SDK - Go
- PHP SDK - PHP
- Publishing Guide - Publish SDKs to package managers
- Implementation Status - Complete feature overview
# Build all crates
cargo build
# Run tests
cargo test
# Start TORM server
cargo run --bin torm-server
# Build release
cargo build --releasetorm/
βββ Cargo.toml # Workspace config
βββ crates/
β βββ torm/ # Core ORM library
β βββ torm-server/ # REST API server
β βββ torm-derive/ # Proc macros
βββ sdks/ # Language SDKs
β βββ nodejs/
β βββ python/
β βββ go/
β βββ php/
βββ examples/ # Example projects
βββ basic-crud/
βββ relationships/
βββ validation/
MIT License - see LICENSE for details
Built with β€οΈ for ToonStore