DatabaseSchema

Trait DatabaseSchema 

Source
pub trait DatabaseSchema {
    // Required methods
    fn referenced_tables(
        &self,
        table: &'static str,
    ) -> Vec<(&'static str, Vec<&'static str>)>;
    fn insert(
        &self,
        dbms: &IcDbmsDatabase,
        table_name: &'static str,
        record_values: &[(ColumnDef, Value)],
    ) -> IcDbmsResult<()>;
    fn delete(
        &self,
        dbms: &IcDbmsDatabase,
        table_name: &'static str,
        delete_behavior: DeleteBehavior,
        filter: Option<Filter>,
    ) -> IcDbmsResult<u64>;
    fn update(
        &self,
        dbms: &IcDbmsDatabase,
        table_name: &'static str,
        patch_values: &[(ColumnDef, Value)],
        filter: Option<Filter>,
    ) -> IcDbmsResult<u64>;
    fn validate_insert(
        &self,
        dbms: &IcDbmsDatabase,
        table_name: &'static str,
        record_values: &[(ColumnDef, Value)],
    ) -> IcDbmsResult<()>;
}
Expand description

This trait provides the schema operation for the current database.

It must provide the functionalities to validate the operations and perform them using the [Database] instance.

This is required because all of the [Database] operations rely on T, a crate::prelude::TableSchema, but we can’t store them inside of transactions without knowing the concrete type at compile time.

Required Methods§

Source

fn referenced_tables( &self, table: &'static str, ) -> Vec<(&'static str, Vec<&'static str>)>

Returns the foreign key definitions referencing other tables for the given table name.

So if a table Post has a foreign key referencing the User table, calling referenced_tables("User") would return a list containing: [("Post, &[“user_id”])]`.

Source

fn insert( &self, dbms: &IcDbmsDatabase, table_name: &'static str, record_values: &[(ColumnDef, Value)], ) -> IcDbmsResult<()>

Performs an insert operation for the given table name and record values.

Use [Database::insert] internally to perform the operation.

Source

fn delete( &self, dbms: &IcDbmsDatabase, table_name: &'static str, delete_behavior: DeleteBehavior, filter: Option<Filter>, ) -> IcDbmsResult<u64>

Performs a delete operation for the given table name, delete behavior, and optional filter.

Use [Database::delete] internally to perform the operation.

Source

fn update( &self, dbms: &IcDbmsDatabase, table_name: &'static str, patch_values: &[(ColumnDef, Value)], filter: Option<Filter>, ) -> IcDbmsResult<u64>

Performs an update operation for the given table name, patch values, and optional filter.

Use [Database::update] internally to perform the operation.

Source

fn validate_insert( &self, dbms: &IcDbmsDatabase, table_name: &'static str, record_values: &[(ColumnDef, Value)], ) -> IcDbmsResult<()>

Validates an insert operation for the given table name and record values.

Use a crate::prelude::InsertIntegrityValidator to perform the validation.

Implementors§