1pub mod pool;
30pub mod transaction;
31pub mod repository;
32
33#[cfg(feature = "cache")]
34pub mod cache;
35
36pub use pool::{DatabasePool, PoolConfig};
37pub use transaction::{Transaction, Transactional};
38pub use repository::{
39 Repository, SoftDelete, ProductScoped, PaginatedRepository,
40 PaginationParams, PaginatedResponse, BaseRepository,
41};
42
43#[cfg(feature = "cache")]
44pub use cache::{CacheManager, CacheAside};
45
46use thiserror::Error;
47
48#[derive(Error, Debug)]
50pub enum DatabaseError {
51 #[error("Connection failed: {0}")]
52 ConnectionFailed(String),
53
54 #[error("Query failed: {0}")]
55 QueryFailed(String),
56
57 #[error("Transaction failed: {0}")]
58 TransactionFailed(String),
59
60 #[error("Not found: {0}")]
61 NotFound(String),
62
63 #[error("Constraint violation: {0}")]
64 ConstraintViolation(String),
65
66 #[cfg(feature = "cache")]
67 #[error("Cache error: {0}")]
68 CacheError(String),
69}
70
71pub type Result<T> = std::result::Result<T, DatabaseError>;