pub struct IcDbmsDatabase { /* private fields */ }Expand description
The main DBMS struct.
This struct serves as the entry point for interacting with the DBMS engine.
It provides methods for executing queries.
Database::select- Execute a SELECT query.Database::insert- Execute an INSERT query.Database::update- Execute an UPDATE query.Database::delete- Execute a DELETE query.Database::commit- Commit the current transaction.Database::rollback- Rollback the current transaction.
The transaction field indicates whether the instance is operating within a transaction context.
The Database can be instantiated for one-shot, with [Database::oneshot] operations (no transaction),
or within a transaction context with [Database::from_transaction].
If a transaction is active, all operations will be part of that transaction until it is committed or rolled back.
Implementations§
Source§impl IcDbmsDatabase
impl IcDbmsDatabase
Sourcepub fn oneshot(schema: impl DatabaseSchema + 'static) -> Self
pub fn oneshot(schema: impl DatabaseSchema + 'static) -> Self
Load an instance of the Database for one-shot operations (no transaction).
Sourcepub fn from_transaction(
schema: impl DatabaseSchema + 'static,
transaction_id: TransactionId,
) -> Self
pub fn from_transaction( schema: impl DatabaseSchema + 'static, transaction_id: TransactionId, ) -> Self
Load an instance of the Database within a transaction context.
Trait Implementations§
Source§impl Database for IcDbmsDatabase
impl Database for IcDbmsDatabase
Source§fn select<T>(&self, query: Query<T>) -> IcDbmsResult<Vec<T::Record>>where
T: TableSchema,
fn select<T>(&self, query: Query<T>) -> IcDbmsResult<Vec<T::Record>>where
T: TableSchema,
Source§fn delete<T>(
&self,
behaviour: DeleteBehavior,
filter: Option<Filter>,
) -> IcDbmsResult<u64>where
T: TableSchema,
fn delete<T>(
&self,
behaviour: DeleteBehavior,
filter: Option<Filter>,
) -> IcDbmsResult<u64>where
T: TableSchema,
Executes a DELETE query.
§Arguments
behaviour- TheDeleteBehaviorto apply for foreign key constraints.filter- An optionalFilterto specify which records to delete.
§Returns
The number of rows deleted.
Source§fn commit(&mut self) -> IcDbmsResult<()>
fn commit(&mut self) -> IcDbmsResult<()>
Commits the current transaction.
The transaction is consumed.
Any error during commit will trap the canister to ensure consistency.
Source§fn rollback(&mut self) -> IcDbmsResult<()>
fn rollback(&mut self) -> IcDbmsResult<()>
Rolls back the current transaction.
The transaction is consumed.