diff --git a/src/database/mod.rs b/src/database/mod.rs index d6cf5d68..351679d6 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -133,21 +133,41 @@ impl ConnectOptions { self } + /// Get the maximum number of connections of the pool, if set + pub fn get_max_connections(&self) -> Option { + self.max_connections + } + /// Set the minimum number of connections of the pool pub fn min_connections(&mut self, value: u32) -> &mut Self { self.min_connections = Some(value); self } + /// Get the minimum number of connections of the pool, if set + pub fn get_min_connections(&self) -> Option { + self.min_connections + } + /// Set the timeout duration when acquiring a connection pub fn connect_timeout(&mut self, value: Duration) -> &mut Self { self.connect_timeout = Some(value); self } + /// Get the timeout duration when acquiring a connection, if set + pub fn get_connect_timeout(&self) -> Option { + self.connect_timeout + } + /// Set the idle duration before closing a connection pub fn idle_timeout(&mut self, value: Duration) -> &mut Self { self.idle_timeout = Some(value); self } + + /// Get the idle duration before closing a connection, if set + pub fn get_idle_timeout(&self) -> Option { + self.idle_timeout + } } diff --git a/src/driver/sqlx_sqlite.rs b/src/driver/sqlx_sqlite.rs index 4e95bbaa..4139a0f9 100644 --- a/src/driver/sqlx_sqlite.rs +++ b/src/driver/sqlx_sqlite.rs @@ -30,7 +30,7 @@ impl SqlxSqliteConnector { pub fn accepts(string: &str) -> bool { string.starts_with("sqlite:") && string.parse::().is_ok() } - + /// Add configuration options for the SQLite database pub async fn connect(options: ConnectOptions) -> Result { let mut opt = options @@ -41,12 +41,10 @@ impl SqlxSqliteConnector { use sqlx::ConnectOptions; opt.disable_statement_logging(); } - if let Ok(pool) = options - .pool_options() - .max_connections(1) - .connect_with(opt) - .await - { + if options.get_max_connections().is_none() { + options.max_connections(1); + } + if let Ok(pool) = options.pool_options().connect_with(opt).await { Ok(DatabaseConnection::SqlxSqlitePoolConnection( SqlxSqlitePoolConnection { pool }, )) diff --git a/src/lib.rs b/src/lib.rs index 8cb1d981..4a505970 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -266,10 +266,15 @@ mod database; mod docs; mod driver; +/// Module for the Entity type and operations pub mod entity; +/// Error types for all database operations pub mod error; +/// This module performs execution of queries on a Model or ActiveModel mod executor; +/// Holds types and methods to perform queries pub mod query; +/// Holds types that defines the schemas of an Entity pub mod schema; #[doc(hidden)] #[cfg(feature = "macros")]