[][src]Trait rbatis::crud::CRUDEnable

pub trait CRUDEnable: Send + Sync + Serialize + DeserializeOwned {
    type IdType: Send + Sync + DeserializeOwned + Serialize + Display;
    fn table_name() -> String { ... }
fn table_columns() -> String { ... }
fn make_column_value_map(
        &self,
        db_type: &DriverType
    ) -> Result<Map<String, Value>> { ... }
fn make_value_sql_arg(
        &self,
        db_type: &DriverType,
        index: &mut usize
    ) -> Result<(String, Vec<Value>)> { ... }
fn format_chain() -> Vec<Box<dyn ColumnFormat>> { ... } }

DB Table model trait

Associated Types

type IdType: Send + Sync + DeserializeOwned + Serialize + Display

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

Loading content...

Provided methods

fn table_name() -> String

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 CRUDEnable for BizActivity{ table_name() -> String{ "biz_activity".to_string() } }

fn table_columns() -> String

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>>

make an Map<table_column,value> TODO macro driver auto create this methods

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

return (value sql,args)

fn format_chain() -> Vec<Box<dyn ColumnFormat>>

return cast chain, you also can rewrite this method, but do not forget push DateFormat(if you need)

Loading content...

Implementations on Foreign Types

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

type IdType = T::IdType

Loading content...

Implementors

Loading content...