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
79
80
81
//! Database connection and pool management
//!
//! This module provides the main `Database` struct for connecting to and
//! interacting with databases. It completely hides the underlying connection
//! pool and ORM implementation.
//!
//! ## Example
//!
//! ```rust,no_run
//! # tideorm::__doctest_prelude!();
//! # async fn demo() -> tideorm::Result<()> {
//!
//! // Simple connection
//! let db = Database::connect("postgres://localhost/myapp").await?;
//!
//! // With options
//! let db = Database::builder()
//! .url("postgres://localhost/myapp")
//! .max_connections(10)
//! .min_connections(2)
//! .connect_timeout(Duration::from_secs(5))
//! .build()
//! .await?;
//!
//! // Transactions
//! db.transaction(|tx| Box::pin(async move {
//! // tx.connection() gives you the transaction connection
//! Ok(())
//! })).await?;
//! # let _ = db;
//! # Ok::<(), tideorm::Error>(())
//! # }
//! ```
//!
//! ## Global Database Connection
//!
//! TideORM supports a global database connection, allowing models to access
//! the database without explicitly passing a connection reference:
//!
//! ```rust,no_run
//! # tideorm::__doctest_prelude!();
//! # async fn demo() -> tideorm::Result<()> {
//! // Initialize global connection (call once at startup)
//! Database::init("postgres://localhost/myapp").await?;
//!
//! // Now models can use the global connection automatically
//! let user = User {
//! id: 0,
//! email: "john@example.com".to_string(),
//! name: "John".to_string(),
//! ..Default::default()
//! };
//!
//! // No need to pass &db - uses global connection automatically
//! let user = user.save().await?;
//! # let _ = user;
//! # Ok::<(), tideorm::Error>(())
//! # }
//! ```
pub use DatabaseBuilder;
pub use Database;
pub use ;
pub use ;
pub use ConnectionRef;
pub use DatabaseHandle;