lume/
lib.rs

1#![warn(missing_docs)]
2
3//! # Lume
4//!
5//! A type-safe, ergonomic schema builder and ORM for SQL databases, inspired by Drizzle ORM.
6//!
7//! ## Features
8//!
9//! - 🚀 **Type-safe**: Compile-time type checking for all database operations
10//! - 🎯 **Ergonomic**: Clean, intuitive API inspired by modern ORMs
11//! - ⚡ **Performance**: Zero-cost abstractions with minimal runtime overhead
12//! - 🔧 **Flexible**: Support for various column constraints and SQL types
13//! - 🛡️ **Safe**: Prevents SQL injection and runtime type errors
14//! - 📦 **Lightweight**: Minimal dependencies, maximum functionality
15//!
16//! ## Quick Start
17//!
18//! ```no_run,ignore
19//! use lume::define_schema;
20//! use lume::schema::{Schema, ColumnInfo, Value};
21//! use lume::database::Database;
22//!
23//! // Define your database schema
24//! define_schema! {
25//!     Users {
26//!         id: i32 [primary_key().not_null()],
27//!         username: String [not_null()],
28//!         email: String,
29//!         age: i32,
30//!         is_active: bool [default_value(true)],
31//!     }
32//! }
33//!
34//! #[tokio::main]
35//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
36//!     // Connect to your MySQL/Postgres database
37//!     let db = Database::connect("mysql://user:password@localhost/database").await?;
38//!     
39//!     // Type-safe queries
40//!     let users = db
41//!         .query::<Users, SelectUsers>()
42//!         .filter(lume::filter::Filter::eq_value("username", Value::String("john_doe".to_string())))
43//!         .execute()
44//!         .await?;
45//!     
46//!     for user in users {
47//!         let username: Option<String> = user.get(Users::username());
48//!         println!("User: {}", username.unwrap_or_default());
49//!     }
50//!     
51//!     Ok(())
52//! }
53//! ```
54//!
55//! ## Supported Database Types
56//!
57//! - `String` → `VARCHAR(255)`
58//! - `i32` → `INTEGER`
59//! - `i64` → `BIGINT`
60//! - `f32` → `FLOAT`
61//! - `f64` → `DOUBLE`
62//! - `bool` → `BOOLEAN`
63//!
64//! ## Column Constraints
65//!
66//! - `primary_key()` - Sets the column as primary key
67//! - `not_null()` - Makes the column NOT NULL
68//! - `unique()` - Adds a UNIQUE constraint
69//! - `indexed()` - Creates an index on the column
70//! - `default_value(value)` - Sets a default value
71
72/// Database connection and management functionality
73pub mod database;
74
75/// Query filtering and condition building
76pub mod filter;
77
78/// Database operations (queries, inserts, etc.)
79pub mod operations;
80
81/// Row abstraction for type-safe data access
82pub mod row;
83
84/// Schema definition and column management
85pub mod schema;
86
87/// Table registry and definition management
88pub mod table;
89
90mod tests;
91
92pub(crate) mod helpers;
93
94mod dialects;