pub struct SqlTransaction<'a, S: KVStore + 'a> { /* private fields */ }Expand description
SQL transaction wrapping a KV transaction.
Provides SQL-friendly access to table and index storage, with explicit commit/rollback control.
Implementations§
Source§impl<'a, S: KVStore + 'a> SqlTransaction<'a, S>
impl<'a, S: KVStore + 'a> SqlTransaction<'a, S>
Sourcepub fn table_storage<'b>(
&'b mut self,
table_meta: &TableMetadata,
) -> TableStorage<'b, 'a, S::Transaction<'a>>
pub fn table_storage<'b>( &'b mut self, table_meta: &TableMetadata, ) -> TableStorage<'b, 'a, S::Transaction<'a>>
Get a table storage handle.
Returns a TableStorage instance that borrows this transaction. The returned storage is valid for the duration of the borrow.
The table_id is obtained from table_meta.table_id.
Sourcepub fn index_storage<'b>(
&'b mut self,
index_id: u32,
unique: bool,
column_indices: Vec<usize>,
) -> IndexStorage<'b, 'a, S::Transaction<'a>>
pub fn index_storage<'b>( &'b mut self, index_id: u32, unique: bool, column_indices: Vec<usize>, ) -> IndexStorage<'b, 'a, S::Transaction<'a>>
Get an index storage handle.
Returns an IndexStorage instance that borrows this transaction. The returned storage is valid for the duration of the borrow.
Sourcepub fn delete_prefix(&mut self, prefix: &[u8]) -> Result<()>
pub fn delete_prefix(&mut self, prefix: &[u8]) -> Result<()>
Delete all keys with the given prefix.
Sourcepub fn with_table<R, F>(
&mut self,
table_meta: &TableMetadata,
f: F,
) -> Result<R>
pub fn with_table<R, F>( &mut self, table_meta: &TableMetadata, f: F, ) -> Result<R>
Execute operations on a table within a closure.
This is a convenience method that creates a TableStorage, executes the closure, and returns the result.
The table_id is obtained from table_meta.table_id.
Sourcepub fn with_index<R, F>(
&mut self,
index_id: u32,
unique: bool,
column_indices: Vec<usize>,
f: F,
) -> Result<R>
pub fn with_index<R, F>( &mut self, index_id: u32, unique: bool, column_indices: Vec<usize>, f: F, ) -> Result<R>
Execute operations on an index within a closure.
This is a convenience method that creates an IndexStorage, executes the closure, and returns the result.