pub struct DatabasePool {
pub pool: Pool<Any>,
pub kind: DatabaseKind,
pub pg_pool: Option<Pool<Postgres>>,
pub sqlite_pool: Option<Pool<Sqlite>>,
}Expand description
Lumina DatabasePool — wrapper di atas sqlx::Pool<Any> dan driver native enterprise (termasuk MSSQL Tiberius).
Fields§
§pool: Pool<Any>§kind: DatabaseKind§pg_pool: Option<Pool<Postgres>>§sqlite_pool: Option<Pool<Sqlite>>Implementations§
Source§impl DatabasePool
impl DatabasePool
Sourcepub async fn connect(database_url: &str) -> Result<DatabasePool, Error>
pub async fn connect(database_url: &str) -> Result<DatabasePool, Error>
Buat koneksi pool baru dari database_url.
Sourcepub async fn begin(&self) -> Result<Transaction, Error>
pub async fn begin(&self) -> Result<Transaction, Error>
Mulai transaksi database baru (ACID Transaction) yang aman, otomatis rollback jika gagal.
Sourcepub async fn begin_transaction(&self) -> Result<Transaction, Error>
pub async fn begin_transaction(&self) -> Result<Transaction, Error>
Mulai transaksi database baru (ACID Transaction) dengan gaya imperatif tanpa closure.
Sourcepub async fn execute_raw(&self, sql: &str) -> Result<u64, Error>
pub async fn execute_raw(&self, sql: &str) -> Result<u64, Error>
Eksekusi SQL raw langsung pada database pool
Sourcepub fn pg(&self) -> Option<&Pool<Postgres>>
pub fn pg(&self) -> Option<&Pool<Postgres>>
Akses direct native PgPool (hanya tersedia jika fitur postgres aktif)
Sourcepub fn sqlite(&self) -> Option<&Pool<Sqlite>>
pub fn sqlite(&self) -> Option<&Pool<Sqlite>>
Akses direct native SqlitePool (hanya tersedia jika fitur sqlite aktif)
Sourcepub fn prepare_sql(&self, sql: &str) -> String
pub fn prepare_sql(&self, sql: &str) -> String
Menyesuaikan placeholder query secara otomatis berdasarkan driver database aktif.
SQLite/MySQL: tetap menggunakan ?.
PostgreSQL: mentranslasikan ? menjadi $1, $2, $3, ....
MSSQL: mentranslasikan ? menjadi @p1, @p2, @p3, ....
Trait Implementations§
Source§impl Clone for DatabasePool
impl Clone for DatabasePool
Source§fn clone(&self) -> DatabasePool
fn clone(&self) -> DatabasePool
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 moreSource§impl<'a> From<&'a DatabasePool> for DbSource<'a>
impl<'a> From<&'a DatabasePool> for DbSource<'a>
Source§fn from(pool: &'a DatabasePool) -> DbSource<'a>
fn from(pool: &'a DatabasePool) -> DbSource<'a>
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for DatabasePool
impl !UnwindSafe for DatabasePool
impl Forget for DatabasePool
impl Freeze for DatabasePool
impl Move for DatabasePool
impl Send for DatabasePool
impl Sync for DatabasePool
impl Unpin for DatabasePool
impl UnsafeUnpin for DatabasePool
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