github rbatis/rbatis v1.8.40

latest releases: v4.5.22, v4.5.21, v4.5.20...
3 years ago

v1.8.40

  • tx_id rename to context_id, use tx_id,ctx_id,context_id Will be recognized by the Rbatis.
  • Rbatis add begin_tx_defer()method and begin_tx()method. begin_tx_defer Used to automatically Drop or Commit transactions after Drop,
    for example:
#[async_std::test]
    pub async fn test_tx_commit_defer() {
        fast_log::init_log("requests.log", 1000, log::Level::Info, None, true);
        let rb: Rbatis = Rbatis::new();
        rb.link(MYSQL_URL).await.unwrap();
        let guard = rb.begin_tx_defer(true).await.unwrap();
        let v: serde_json::Value = rb.fetch(&guard.tx_id, "SELECT count(1) FROM biz_activity;").await.unwrap();
        // tx will be commit
        drop(guard);
        println!("{}", v.clone());
        sleep(Duration::from_secs(1));
    }

2020-12-03 14:53:24.908263 +08:00    INFO rbatis::plugin::log - [rbatis] [tx:4b190951-7a94-429a-b253-3ec3df487b57] Begin
2020-12-03 14:53:24.909074 +08:00    INFO rbatis::plugin::log - [rbatis] [tx:4b190951-7a94-429a-b253-3ec3df487b57] Query ==> SELECT count(1) FROM biz_activity;
2020-12-03 14:53:24.912973 +08:00    INFO rbatis::plugin::log - [rbatis] [tx:4b190951-7a94-429a-b253-3ec3df487b57] ReturnRows <== 1
2020-12-03 14:53:24.914487 +08:00    INFO rbatis::plugin::log - [rbatis] [tx:4b190951-7a94-429a-b253-3ec3df487b57] Commit

begin_tx() method Automatically generate transactions that use UUIDs

    pub async fn test_tx_commit() {
        fast_log::init_log("requests.log", 1000, log::Level::Info, None, true);
        let rb: Rbatis = Rbatis::new();
        rb.link(MYSQL_URL).await.unwrap();
        let tx_id = rb.begin_tx().await.unwrap();
        let v: serde_json::Value = rb.fetch(&tx_id, "SELECT count(1) FROM biz_activity;").await.unwrap();
        println!("{}", v.clone());
        rb.commit(&tx_id).await.unwrap();
    }

Don't miss a new rbatis release

NewReleases is sending notifications on new releases.