Struct rbatis::rbatis::Rbatis [−][src]
pub struct Rbatis {
pub pool: OnceCell<DBPool>,
pub page_plugin: Box<dyn PagePlugin>,
pub sql_intercepts: Vec<Box<dyn SqlIntercept>>,
pub log_plugin: Arc<Box<dyn LogPlugin>>,
pub logic_plugin: Option<Box<dyn LogicDelete>>,
pub encoder: fn(q: &mut DBQuery<'_>, arg: Bson) -> Result<()>,
}
Expand description
rbatis engine
Fields
pool: OnceCell<DBPool>
page_plugin: Box<dyn PagePlugin>
sql_intercepts: Vec<Box<dyn SqlIntercept>>
log_plugin: Arc<Box<dyn LogPlugin>>
logic_plugin: Option<Box<dyn LogicDelete>>
encoder: fn(q: &mut DBQuery<'_>, arg: Bson) -> Result<()>
Implementations
new Rbatis from Option
try return an new wrapper,if not call the link() method,it will be panic!
try return an new wrapper and set table formats,if not call the link() method,it will be panic!
link pool by DBPoolOptions for example: let mut opt = PoolOptions::new(); opt.max_size = 20; rb.link_opt(“mysql://root:123456@localhost:3306/test”, opt).await.unwrap();
pub async fn link_cfg(
&self,
connect_option: &DBConnectOption,
pool_options: DBPoolOptions
) -> Result<(), Error>
pub async fn link_cfg(
&self,
connect_option: &DBConnectOption,
pool_options: DBPoolOptions
) -> Result<(), Error>
link pool by DBConnectOption and DBPoolOptions for example: let db_cfg=DBConnectOption::from(“mysql://root:123456@localhost:3306/test”)?; rb.link_cfg(&db_cfg,PoolOptions::new());
get driver type
get an DataBase Connection used for the next step
get an DataBase Connection,and call begin method,used for the next step
is debug mode
change ref to executor
Trait Implementations
fn update_by_wrapper<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
table: &'life1 T,
w: Wrapper,
skips: &'life2 [Skip<'_>]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn update_by_wrapper<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
table: &'life1 T,
w: Wrapper,
skips: &'life2 [Skip<'_>]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
update_by_wrapper skips: use &[Skip::Value(&bson::Bson::Null), Skip::Column(“id”), Skip::Column(column)] will skip id column and null value param
fn fetch_page<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
sql: &'life1 str,
args: Vec<Bson>,
page_request: &'life2 dyn IPageRequest
) -> Pin<Box<dyn Future<Output = Result<Page<T>>> + Send + 'async_trait>> where
T: DeserializeOwned + Serialize + Send + Sync,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn fetch_page<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
sql: &'life1 str,
args: Vec<Bson>,
page_request: &'life2 dyn IPageRequest
) -> Pin<Box<dyn Future<Output = Result<Page<T>>> + Send + 'async_trait>> where
T: DeserializeOwned + Serialize + Send + Sync,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fetch page result(prepare sql)
fn save_by_wrapper<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
table: &'life1 T,
w: Wrapper,
skips: &'life2 [Skip<'_>]
) -> Pin<Box<dyn Future<Output = Result<DBExecResult>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn save<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
table: &'life1 T,
skips: &'life2 [Skip<'_>]
) -> Pin<Box<dyn Future<Output = Result<DBExecResult>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn save_batch<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
tables: &'life1 [T],
skips: &'life2 [Skip<'_>]
) -> Pin<Box<dyn Future<Output = Result<DBExecResult>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn save_batch_slice<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
tables: &'life1 [T],
slice_len: usize,
skips: &'life2 [Skip<'_>]
) -> Pin<Box<dyn Future<Output = Result<DBExecResult>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn save_batch_slice<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
tables: &'life1 [T],
slice_len: usize,
skips: &'life2 [Skip<'_>]
) -> Pin<Box<dyn Future<Output = Result<DBExecResult>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
save_batch_slice batch save each slice_len every time Read more
fn remove_by_wrapper<'life0, 'async_trait, T>(
&'life0 self,
w: Wrapper
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn remove_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
value: &'life2 P
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn remove_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
value: &'life2 P
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
remove_by_column column_value,column’s value Read more
fn remove_batch_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
values: &'life2 [P]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn remove_batch_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
values: &'life2 [P]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
remove_batch_by_column column_values,column’s value Read more
fn update_by_column<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
column: &'life1 str,
table: &'life2 T
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn update_by_column<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
column: &'life1 str,
table: &'life2 T
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
update database record by id
fn update_batch_by_column<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
column: &'life1 str,
args: &'life2 [T]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn update_batch_by_column<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
column: &'life1 str,
args: &'life2 [T]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
T: CRUDTable,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
remove batch database record by args
fn fetch_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
value: &'life2 P
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn fetch_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
value: &'life2 P
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fetch database record by id
fn fetch_by_wrapper<'life0, 'async_trait, T>(
&'life0 self,
w: Wrapper
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn fetch_by_wrapper<'life0, 'async_trait, T>(
&'life0 self,
w: Wrapper
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fetch database record by a wrapper
count database record
count database record by a wrapper
fn fetch_page_by_wrapper<'life0, 'life1, 'async_trait, T>(
&'life0 self,
w: Wrapper,
page: &'life1 dyn IPageRequest
) -> Pin<Box<dyn Future<Output = Result<Page<T>>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_page_by_wrapper<'life0, 'life1, 'async_trait, T>(
&'life0 self,
w: Wrapper,
page: &'life1 dyn IPageRequest
) -> Pin<Box<dyn Future<Output = Result<Page<T>>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fetch page database record list by a wrapper
fn fetch_list<'life0, 'async_trait, T>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn fetch_list<'life0, 'async_trait, T>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fetch database record list for all
fn fetch_list_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
column_values: &'life2 [P]
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn fetch_list_by_column<'life0, 'life1, 'life2, 'async_trait, T, P>(
&'life0 self,
column: &'life1 str,
column_values: &'life2 [P]
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>> where
T: CRUDTable + DeserializeOwned,
P: Serialize + Send + Sync,
T: 'async_trait,
P: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fetch database record list by a id array