TideORM
A developer-friendly ORM for Rust with clean, expressive syntax.
Features
- Clean Model Definitions - Simple
#[tideorm::model(table = "...")]attribute macro - Field-Declared Relations -
HasOne,HasMany,BelongsTo, andHasManyThroughrelations are defined directly on the model - Async-First - Built for modern async/await workflows
- Auto Schema Sync - Automatic table management during development
- Multi-Database - PostgreSQL, MySQL, and SQLite support
- Query Builder - Fluent filtering, OR groups, joins, unions, CTEs, and window functions
- Profiling & Logging - Built-in query logging plus execution counters and slow-query stats
- Data Lifecycle Tools - Migrations, seeding, validation, callbacks, soft deletes, and transactions
- Optional Modules - Attachments, translations, and full-text search are available behind feature flags
- Tokenization - Secure record ID encoding/decoding helpers
Quick Start
use *;
async
Relation helper fields like HasOne<T> and HasMany<T> are runtime-only. TideORM's generated serde support skips them, so they do not appear in JSON payloads and are restored with defaults on deserialize.
Composite primary keys are supported by marking multiple fields with #[tideorm(primary_key)]. Composite keys are used as tuples in CRUD APIs, for example UserRole::find((user_id, role_id)). auto_increment and tokenization remain single-primary-key features.
For batch inserts, use Model::insert_all(...). It is TideORM's single bulk-insert API and returns the inserted models with database-generated values populated when the active backend supports or emulates that behavior.
For tests and reconfiguration-heavy workflows, TideORM's global state is resettable. Use Database::reset_global(), TideConfig::reset(), and TokenConfig::reset() before applying a fresh setup.
Profiling
TideORM ships with two profiling layers:
GlobalProfilerrecords aggregate timings for real executed queries when enabled.Profilerbuilds manual profiling reports from queries you record explicitly.
use *;
use GlobalProfiler;
enable;
reset;
let _ = query.where_eq.get.await?;
let stats = stats;
println!;
disable;
The global profiler now observes the main TideORM execution paths, including query-builder reads, raw SQL helpers, aggregate queries, full-text search, and macro-generated CRUD methods.
Model Relations
TideORM supports SeaORM-style relations defined as struct fields:
// Loading relations
let user = find.await?.unwrap;
let posts = user.posts.load.await?; // Vec<Post>
let profile = user.profile.load.await?; // Option<Profile>
let post = find.await?.unwrap;
let author = post.author.load.await?; // Option<User>
// Check if relation exists
let has_posts = user.posts.exists.await?; // bool
let post_count = user.posts.count.await?; // u64
// Load with constraints
let recent_posts = user.posts.load_with.await?;
Installation
[]
# PostgreSQL (default)
= { = "0.9.2", = ["postgres"] }
# MySQL
= { = "0.9.2", = ["mysql"] }
# SQLite
= { = "0.9.2", = ["sqlite"] }
# Enable attachments support explicitly
= { = "0.9.2", = ["postgres", "attachments"] }
# Enable translations support explicitly
= { = "0.9.2", = ["postgres", "translations"] }
# Enable full-text search support explicitly
= { = "0.9.2", = ["postgres", "fulltext"] }
Feature Flags
| Feature | Description |
|---|---|
postgres |
PostgreSQL support (default) |
mysql |
MySQL/MariaDB support |
sqlite |
SQLite support |
runtime-tokio |
Tokio runtime (default) |
runtime-async-std |
async-std runtime |
attachments |
Compile-time-only feature gate for the attachments API and attachment-specific benchmarks/tests; adds no extra dependencies |
translations |
Compile-time-only feature gate for the translations API and translation-specific benchmarks/tests; adds no extra dependencies |
fulltext |
Compile-time-only feature gate for the full-text search API and fulltext-specific benchmarks/tests; adds no extra dependencies |
Attachments are opt-in. Enable the attachments feature when you want to use tideorm::attachments, HasAttachments, or attachment URL generation helpers. This is a compile-time API gate only; it does not pull in additional crates.
Translations are opt-in. Enable the translations feature when you want to use tideorm::translations, HasTranslations, or ApplyTranslations. This is a compile-time API gate only; it does not pull in additional crates.
Full-text search is opt-in. Enable the fulltext feature when you want to use tideorm::fulltext, FullTextSearch, or the highlighting helpers. This is a compile-time API gate only; it does not pull in additional crates.
Relation Types
| Type | Description | Example |
|---|---|---|
HasOne<T> |
One-to-one relationship | User has one Profile |
HasMany<T> |
One-to-many relationship | User has many Posts |
BelongsTo<T> |
Inverse of HasOne/HasMany | Post belongs to User |
HasManyThrough<T, P> |
Many-to-many via pivot | User has many Roles through UserRoles |
Annotated relation fields are initialized automatically on models loaded through TideORM. Polymorphic relation wrappers exist, but they still require manual .with_parent(...) setup instead of macro-generated wiring.
Documentation
The docs now ship as an mdBook.
- Read the book locally in the repo: docs/introduction.md
- Published site: tideorm.com
- Lightweight markdown index: DOCUMENTATION.md
- Rebuild the generated site locally with
mdbook buildor preview it withmdbook serve --open
Core chapters:
- Getting Started - Configuration, type mappings, examples, and testing
- Models - Model definition, CRUD behavior, lifecycle hooks, validation, tokenization, and SeaORM 2.0-inspired helpers
- Queries - Query builder, full-text search, multi-database behavior, raw SQL, logging, and errors
- Profiling - Global query timing, slow-query stats, manual reports, and query analysis
- Relations - Field-declared relations, attachments, translations, and runtime relation wrappers
- Migrations - Schema builder column types, migration authoring, and schema sync guidance
Ecosystem
This repository is the core TideORM library. Related projects live separately:
- TideORM CLI - External command-line tooling for TideORM
- TideORM Examples - End-to-end example applications and demos
Examples
For runnable applications and broader demos, see tideorm-examples.
Testing
TideORM ships with unit, integration, and feature-specific test coverage. The repository CI runs cargo fmt, cargo clippy, cargo check, cargo test --lib across PostgreSQL, MySQL, and SQLite feature sets, plus a SQLite end-to-end smoke test.
Common local commands:
# Fast library validation
# Full suite for a backend feature set
# Cross-backend compile/test coverage
See docs/getting-started.md for more.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.