#mysql #orm #postgres #sqlite #macro #macros #driver #tokio-async-std

macro rbatis-macro-driver

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

118 stable releases

3.0.5 Dec 9, 2021
3.0.4 Nov 23, 2021
2.1.0 Sep 22, 2021
2.0.9 Jun 21, 2021
1.8.38 Nov 30, 2020

#581 in Database interfaces

Download history 202/week @ 2021-09-25 85/week @ 2021-10-02 323/week @ 2021-10-09 166/week @ 2021-10-16 291/week @ 2021-10-23 280/week @ 2021-10-30 402/week @ 2021-11-06 359/week @ 2021-11-13 252/week @ 2021-11-20 262/week @ 2021-11-27 374/week @ 2021-12-04 236/week @ 2021-12-11 197/week @ 2021-12-18 253/week @ 2021-12-25 305/week @ 2022-01-01 196/week @ 2022-01-08

966 downloads per month
Used in rbatis

Apache-2.0

39KB
931 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_log("requests.log", log::Level::Info, None, true);
        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

~3–4MB
~77K SLoC

ױa