pub struct DatabaseConfig {
pub default: String,
pub connections: IndexMap<String, ConnectionConfig>,
}Expand description
Database configuration. Mirrors Laravel’s config/database.php:
- A
defaultconnection name (referenced by models, query builder, migrator). - A map of named connections — each with its own URL, pool size, optional read replicas.
The default from_env() impl auto-builds a single default connection
from DATABASE_URL + DB_POOL. Apps wanting multiple connections set:
DB_CONNECTIONS=default,replica,analytics
DATABASE_URL=postgres://... # the "default" connection
DB_REPLICA_URL=postgres://replica/...
DB_ANALYTICS_URL=postgres://analytics/...
DB_DEFAULT=defaultFields§
§default: String§connections: IndexMap<String, ConnectionConfig>Implementations§
Source§impl DatabaseConfig
impl DatabaseConfig
pub fn from_env() -> Self
Sourcepub fn default_url(&self) -> &str
pub fn default_url(&self) -> &str
Convenience: the URL of the default connection.
Sourcepub fn default_pool_size(&self) -> u32
pub fn default_pool_size(&self) -> u32
Convenience: the pool size of the default connection.
Trait Implementations§
Source§impl Clone for DatabaseConfig
impl Clone for DatabaseConfig
Source§fn clone(&self) -> DatabaseConfig
fn clone(&self) -> DatabaseConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnsafeUnpin for DatabaseConfig
impl UnwindSafe for DatabaseConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more