Trait rbatis::crud::CRUDTable[][src]

pub trait CRUDTable: Send + Sync + Serialize + DeserializeOwned {
    type IdType: Send + Sync + Clone + Serialize + Display + Eq + PartialEq;
    fn get_id(&self) -> Option<&Self::IdType>;

    fn id_name() -> String { ... }
fn table_name() -> String { ... }
fn table_columns() -> String { ... }
fn make_column_value_map(
        &self,
        db_type: &DriverType
    ) -> Result<Map<String, Value>> { ... }
fn do_format_column(
        driver_type: &DriverType,
        column: &str,
        data: String
    ) -> String { ... }
fn make_value_sql_arg(
        &self,
        db_type: &DriverType,
        index: &mut usize
    ) -> Result<(String, String, Vec<Value>)> { ... }
fn formats(
        driver_type: &DriverType
    ) -> HashMap<String, fn(arg: &str) -> String> { ... } }

DataBase Table Model trait

if use #crud_enable impl Table struct, for example: #[crud_enable(id_name:“id”|id_type:“String”|table_name:“biz_activity”|table_columns:“id,name,version,delete_flag”|formats_pg:“id:{}::uuid”)]

if use impl CRUDTable for Table struct, you must impl IdType and id_name() method!

Associated Types

type IdType: Send + Sync + Clone + Serialize + Display + Eq + PartialEq[src]

your table id type,for example: IdType = String IdType = i32

Loading content...

Required methods

fn get_id(&self) -> Option<&Self::IdType>[src]

get struct id field

Loading content...

Provided methods

fn id_name() -> String[src]

table id column

fn table_name() -> String[src]

get table name,default is type name for snake name

for Example: struct BizActivity{} => “biz_activity” also. you can overwrite this method return ture name

impl CRUDTable for BizActivity{ table_name() -> String{ “biz_activity”.to_string() } }

fn table_columns() -> String[src]

get table fields string

for Example: “create_time,delete_flag,h5_banner_img,h5_link,id,name,pc_banner_img,pc_link,remark,sort,status,version”

you also can impl this method for static string

fn make_column_value_map(
    &self,
    db_type: &DriverType
) -> Result<Map<String, Value>>
[src]

make an Map<table_column,value>

fn do_format_column(
    driver_type: &DriverType,
    column: &str,
    data: String
) -> String
[src]

format column

fn make_value_sql_arg(
    &self,
    db_type: &DriverType,
    index: &mut usize
) -> Result<(String, String, Vec<Value>)>
[src]

return (columns_sql,values_sql,args)

fn formats(driver_type: &DriverType) -> HashMap<String, fn(arg: &str) -> String>[src]

return cast chain column:format_str for example: HashMap<“id”,|arg|“{}::uuid”.to_string()>

Loading content...

Implementations on Foreign Types

impl<T> CRUDTable for Option<T> where
    T: CRUDTable
[src]

type IdType = T::IdType

Loading content...

Implementors

Loading content...