pub struct Transaction { /* private fields */ }Expand description
Lumina Transaction Handle — representasi transaksi database ACID yang ergonomis, bebas anotasi seumur hidup (lifetimes), thread-safe, dan auto-rollback on drop.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn from_sqlx(
kind: DatabaseKind,
tx: Transaction<'static, Any>,
) -> Transaction
pub fn from_sqlx( kind: DatabaseKind, tx: Transaction<'static, Any>, ) -> Transaction
Membuat instance transaksi baru dari sqlx transaction.
Sourcepub fn kind(&self) -> DatabaseKind
pub fn kind(&self) -> DatabaseKind
Jenis driver database transaksi ini.
Sourcepub fn prepare_sql(&self, sql: &str) -> String
pub fn prepare_sql(&self, sql: &str) -> String
Menyesuaikan placeholder SQL query (?, $1, @p1) sesuai driver database.
Sourcepub async fn commit(&self) -> Result<(), Error>
pub async fn commit(&self) -> Result<(), Error>
Commit seluruh perubahan data dalam transaksi ini ke database secara permanen.
Sourcepub async fn rollback(&self) -> Result<(), Error>
pub async fn rollback(&self) -> Result<(), Error>
Batalkan seluruh perubahan data dalam transaksi ini (Rollback manual).
Sourcepub async fn savepoint(&self, name: &str) -> Result<(), Error>
pub async fn savepoint(&self, name: &str) -> Result<(), Error>
Buat Savepoint bertingkat di dalam transaksi aktif.
Sourcepub async fn rollback_to(&self, name: &str) -> Result<(), Error>
pub async fn rollback_to(&self, name: &str) -> Result<(), Error>
Batalkan perubahan hanya sampai ke titik Savepoint tertentu.
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 sederhana di dalam transaksi.
Sourcepub fn table(&self, name: &'static str) -> TableQueryBuilder
pub fn table(&self, name: &'static str) -> TableQueryBuilder
Inisialisasi query builder berbasis nama tabel langsung TANPA sintaks generic <>.
Contoh: tx.table("accounts").where_eq("id", 1).decrement("balance", 50000).await?;
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Drop for Transaction
impl Drop for Transaction
Source§impl<'a> From<&'a Transaction> for DbSource<'a>
impl<'a> From<&'a Transaction> for DbSource<'a>
Source§fn from(tx: &'a Transaction) -> DbSource<'a>
fn from(tx: &'a Transaction) -> DbSource<'a>
Auto Trait Implementations§
impl !RefUnwindSafe for Transaction
impl !UnwindSafe for Transaction
impl Forget for Transaction
impl Freeze for Transaction
impl Move for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
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
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> ⓘ
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> ⓘ
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