#actix-web #mysql #orm #rocket #postgres #macro #macros #sql #sqlite #driver

macro rbatis-macro-driver

rbatis macro driver 高性能Rust orM框架 宏系统支持

121 stable releases

Uses new Rust 2021

3.1.2 May 30, 2022
3.1.1 Mar 17, 2022
3.0.5 Dec 9, 2021
3.0.4 Nov 23, 2021
1.8.38 Nov 30, 2020

#305 in Database interfaces

Download history 746/week @ 2022-03-15 768/week @ 2022-03-22 230/week @ 2022-03-29 282/week @ 2022-04-05 236/week @ 2022-04-12 319/week @ 2022-04-19 1119/week @ 2022-04-26 1028/week @ 2022-05-03 2028/week @ 2022-05-10 565/week @ 2022-05-17 833/week @ 2022-05-24 1343/week @ 2022-05-31 606/week @ 2022-06-07 478/week @ 2022-06-14 515/week @ 2022-06-21 276/week @ 2022-06-28

2,017 downloads per month
Used in 3 crates (via rbatis)

Apache-2.0

38KB
833 lines

rbatis macro driver

rbatis的过程宏项目,免去手写 impl CRUDTable 接口的实现简化操作

use way,使用方法

toml

#rbatis dep
rbatis = { path = "../" }
rbatis-core = { path = "../rbatis-core", features = ["all"] }
rbatis-macro-driver = { path = "../rbatis-macro-driver" }

code


#[macro_use]
extern crate rbatis_macro_driver;

///数据库表模型,支持BigDecimal ,DateTime ,rust基本类型(int,float,uint,string,Vec,Array)
/// CRUDTable 特性会自动识别 id为表的id类型(识别String),自动识别结构体名称为蛇形命名的表名 biz_activity。没有id的表 请手动指定
#[derive(CRUDTable, Serialize, Deserialize, Clone, Debug)]
pub struct BizActivity {
    pub id: Option<String>,
    pub name: Option<String>,
    pub pc_link: Option<String>,
    pub h5_link: Option<String>,
    pub pc_banner_img: Option<String>,
    pub h5_banner_img: Option<String>,
    pub sort: Option<String>,
    pub status: Option<i32>,
    pub remark: Option<String>,
    pub create_time: Option<NaiveDateTime>,
    pub version: Option<i32>,
    pub delete_flag: Option<i32>,
}
#[tokio::main]
async fn main() {
        fast_log::init(fast_log::config::Config::new().console());
        let rb = Rbatis::new();
        rb.link("mysql://root:123456@localhost:3306/test").await.unwrap();
        let r = rb.fetch_by_id::<Option<BizActivity>>("", &"1".to_string()).await.unwrap();
        println!("{}", serde_json::to_string(&r).unwrap());
}

Dependencies

~1.7–2.5MB
~54K SLoC