1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! # grorm — A goroutine-native async ORM for Rust
//!
//! `grorm` (GRoutines + ORM) is a database ORM built on top of [gorust](https://crates.io/crates/gorust),
//! providing a goroutine-native async experience without tokio. It supports PostgreSQL, MySQL, and SQLite.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use grorm::{ConnectionConfig, ConnectionPool, SqliteDriverFactory, QueryBuilder, Value};
//! use grorm::DeriveModel;
//! use gorust::runtime;
//!
//! #[derive(Debug, DeriveModel)]
//! #[table = "users"]
//! struct User {
//! id: i64,
//! #[index]
//! name: String,
//! #[unique]
//! email: String,
//! age: i32,
//! }
//!
//! #[runtime]
//! fn main() -> Result<(), grorm::Error> {
//! let config = ConnectionConfig::sqlite("test.db");
//! let pool = ConnectionPool::new(SqliteDriverFactory, config, 4);
//! let mut conn = pool.get()?;
//!
//! let mut qb = QueryBuilder::<User>::new(conn.driver_mut());
//!
//! // Create table with indexes
//! qb.create_table()?;
//!
//! // Insert
//! let user = User { id: 0, name: "Alice".into(), email: "alice@x.com".into(), age: 30 };
//! qb.insert(&user)?;
//!
//! // Chainable query
//! let users = qb.where_eq("name", Value::from("Alice")).find()?;
//! println!("{:?}", users);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Features
//!
//! - **Multi-database**: PostgreSQL, MySQL, SQLite
//! - **Chainable API**: `where_eq().limit().offset().order().find()`
//! - **Transactions**: `Transaction::begin()` with auto-rollback on drop
//! - **Auto table creation**: `create_table()` generates DDL from model
//! - **Index & unique constraints**: `#[index]`, `#[unique]`, `#[unique_index = "name"]`
//! - **JOIN support**: `left_join()`, `inner_join()`, `right_join()`
//! - **IN queries**: `where_in("name", vec![...])`
//! - **Connection pooling**: gorust channel-based pool
//! - **Derive macros**: `#[derive(DeriveModel)]` auto-generates Model trait
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ConnectionPool;
pub use ;
// 明确区分 trait 和 derive macro
pub use Model as DeriveModel;
pub use Table as DeriveTable;