pub trait Database {
// Required methods
fn select<T>(&self, query: Query<T>) -> IcDbmsResult<Vec<T::Record>>
where T: TableSchema;
fn insert<T>(&self, record: T::Insert) -> IcDbmsResult<()>
where T: TableSchema,
T::Insert: InsertRecord<Schema = T>;
fn update<T>(&self, patch: T::Update) -> IcDbmsResult<u64>
where T: TableSchema,
T::Update: UpdateRecord<Schema = T>;
fn delete<T>(
&self,
behaviour: DeleteBehavior,
filter: Option<Filter>,
) -> IcDbmsResult<u64>
where T: TableSchema;
fn commit(&mut self) -> IcDbmsResult<()>;
fn rollback(&mut self) -> IcDbmsResult<()>;
}Expand description
This module defines the Database trait and related database functionalities.
Required Methods§
Sourcefn 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,
Sourcefn insert<T>(&self, record: T::Insert) -> IcDbmsResult<()>
fn insert<T>(&self, record: T::Insert) -> IcDbmsResult<()>
Sourcefn update<T>(&self, patch: T::Update) -> IcDbmsResult<u64>
fn update<T>(&self, patch: T::Update) -> IcDbmsResult<u64>
Sourcefn 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.
Sourcefn 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.
Sourcefn rollback(&mut self) -> IcDbmsResult<()>
fn rollback(&mut self) -> IcDbmsResult<()>
Rolls back the current transaction.
The transaction is consumed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.