[][src]Struct rbatis::rbatis::Rbatis

pub struct Rbatis {
    pub pool: OnceCell<DBPool>,
    pub engine: RbatisEngine,
    pub mapper_node_map: HashMap<String, HashMap<String, NodeType>>,
    pub tx_context: DashMap<String, DBTx>,
    pub page_plugin: Box<dyn PagePlugin>,
    pub sql_intercepts: Vec<Box<dyn SqlIntercept>>,
    pub logic_plugin: Option<Box<dyn LogicDelete>>,
}

rbatis engine

Fields

pool: OnceCell<DBPool>engine: RbatisEnginemapper_node_map: HashMap<String, HashMap<String, NodeType>>tx_context: DashMap<String, DBTx>page_plugin: Box<dyn PagePlugin>sql_intercepts: Vec<Box<dyn SqlIntercept>>logic_plugin: Option<Box<dyn LogicDelete>>

Implementations

impl Rbatis[src]

pub fn new() -> Self[src]

pub fn new_wrapper(&self) -> Wrapper[src]

try return an new wrapper,if not call the link() method,it will be panic!

pub fn check(&self)[src]

link pool

link pool by options for example:

pub fn load_xml(&mut self, mapper_name: &str, data: &str) -> Result<(), Error>[src]

load xml data into rbatis

pub fn get_pool(&self) -> Result<&DBPool, Error>[src]

get conn pool

pub fn driver_type(&self) -> Result<DriverType, Error>[src]

get driver type

pub async fn begin<'_, '_>(&'_ self, new_tx_id: &'_ str) -> Result<u64, Error>[src]

begin tx,for new conn

pub async fn begin_with_conn<'_, '_>(
    &'_ self,
    new_tx_id: &'_ str,
    db_conn: DBPoolConn
) -> Result<u64, Error>
[src]

begin tx,with an exist conn

pub async fn commit<'_, '_>(
    &'_ self,
    tx_id: &'_ str
) -> Result<DBPoolConn, Error>
[src]

commit tx,and return conn

pub async fn rollback<'_, '_>(
    &'_ self,
    tx_id: &'_ str
) -> Result<DBPoolConn, Error>
[src]

rollback tx,and return conn

pub async fn fetch<T, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    sql: &'_ str
) -> Result<T, Error> where
    T: DeserializeOwned
[src]

fetch result(row sql)

pub async fn exec<'_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    sql: &'_ str
) -> Result<u64, Error>
[src]

exec sql(row sql)

pub async fn fetch_prepare<T, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    sql: &'_ str,
    args: &'_ Vec<Value>
) -> Result<T, Error> where
    T: DeserializeOwned
[src]

fetch result(prepare sql)

pub async fn exec_prepare<'_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    sql: &'_ str,
    args: &'_ Vec<Value>
) -> Result<u64, Error>
[src]

exec sql(prepare sql)

pub async fn xml_fetch<T, Ser, '_, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    mapper: &'_ str,
    method: &'_ str,
    arg: &'_ Ser
) -> Result<T, Error> where
    T: DeserializeOwned,
    Ser: Serialize + Send + Sync
[src]

fetch result(prepare sql)

pub async fn xml_exec<Ser, '_, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    mapper: &'_ str,
    method: &'_ str,
    arg: &'_ Ser
) -> Result<u64, Error> where
    Ser: Serialize + Send + Sync
[src]

exec sql(prepare sql)

pub async fn py_fetch<T, Ser, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    py: &'_ str,
    arg: &'_ Ser
) -> Result<T, Error> where
    T: DeserializeOwned,
    Ser: Serialize + Send + Sync
[src]

fetch query result(prepare sql) for example:

     let py = r#"
 SELECT * FROM biz_activity
WHERE delete_flag = #{delete_flag}
 if name != null:
   AND name like #{name+'%'}
 if ids != null:
   AND id in (
   trim ',':
      for item in ids:
        #{item},
   )"#;
     let data: serde_json::Value = rb.py_fetch("", py, &json!({   "delete_flag": 1 })).await.unwrap();

pub async fn py_exec<Ser, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    py: &'_ str,
    arg: &'_ Ser
) -> Result<u64, Error> where
    Ser: Serialize + Send + Sync
[src]

exec sql(prepare sql) for example:

     let py = r#"
 SELECT * FROM biz_activity
WHERE delete_flag = #{delete_flag}
 if name != null:
   AND name like #{name+'%'}
 if ids != null:
   AND id in (
   trim ',':
      for item in ids:
        #{item},
   )"#;
     let data: u64 = rb.py_exec("", py, &json!({   "delete_flag": 1 })).await.unwrap();

pub async fn fetch_page<T, '_, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    sql: &'_ str,
    args: &'_ Vec<Value>,
    page_request: &'_ dyn IPageRequest
) -> Result<Page<T>, Error> where
    T: DeserializeOwned + Serialize + Send + Sync
[src]

fetch page result(prepare sql)

pub async fn xml_fetch_page<T, Ser, '_, '_, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    mapper: &'_ str,
    method: &'_ str,
    arg: &'_ Ser,
    page: &'_ dyn IPageRequest
) -> Result<Page<T>, Error> where
    T: DeserializeOwned + Serialize + Send + Sync,
    Ser: Serialize + Send + Sync
[src]

fetch result(prepare sql)

pub async fn py_fetch_page<T, Ser, '_, '_, '_, '_, '_>(
    &'_ self,
    tx_id: &'_ str,
    py: &'_ str,
    arg: &'_ Ser,
    page: &'_ dyn IPageRequest
) -> Result<Page<T>, Error> where
    T: DeserializeOwned + Serialize + Send + Sync,
    Ser: Serialize + Send + Sync
[src]

fetch result(prepare sql)

Trait Implementations

impl CRUD for Rbatis[src]

fn save<'life0, 'life1, 'life2, 'async_trait, T>(
    &'life0 self,
    tx_id: &'life1 str,
    entity: &'life2 T
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
    T: CRUDEnable,
    T: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

save one entity to database

fn save_batch<'life0, 'life1, 'life2, 'async_trait, T>(
    &'life0 self,
    tx_id: &'life1 str,
    args: &'life2 [T]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
    T: CRUDEnable,
    T: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

save batch makes many value into only one sql. make sure your data not to long!

for Example: rb.save_batch(&vec![activity]); [rbatis] Exec ==> INSERT INTO biz_activity (id,name,version) VALUES ( ? , ? , ?),( ? , ? , ?)

fn remove_batch_by_id<'life0, 'life1, 'life2, 'async_trait, T>(
    &'life0 self,
    tx_id: &'life1 str,
    ids: &'life2 [T::IdType]
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
    T: CRUDEnable,
    T: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

remove batch id for Example : rb.remove_batch_by_id::(&["1".to_string(),"2".to_string()]).await; [rbatis] Exec ==> DELETE FROM biz_activity WHERE id IN ( ? , ? )

fn update_by_wrapper<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
    &'life0 self,
    tx_id: &'life1 str,
    arg: &'life2 T,
    w: &'life3 Wrapper,
    update_null_value: bool
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where
    T: CRUDEnable,
    T: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

update arg by wrapper

impl<'r> Default for Rbatis[src]

Auto Trait Implementations

impl !RefUnwindSafe for Rbatis

impl Send for Rbatis

impl Sync for Rbatis

impl Unpin for Rbatis

impl !UnwindSafe for Rbatis

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,