Rust Compile Time ORM robustness,async, pure Rust Dynamic SQL
APACHE-2.0 License
Bot releases are hidden (Show)
Published by zhuxiujia almost 4 years ago
v1.8.20
for example(this example will be 'for' first ,then to do 'trim'):
#[py_sql(RB, "insert into biz_activity
(
trim ',': for key,item in arg:
${key},
) VALUES (
trim ',': for v in arg:
#{v},
) ")]
pub async fn py_insert(arg: &BizActivity) -> DBExecResult {}
2020-11-15 22:18:07.008296500 +08:00 INFO rbatis::plugin::log - [rbatis] [] Exec ==> insert into biz_activity ( create_time, delete_flag, h5_banner_img, h5_link, id, name, pc_banner_img, pc_link, remark, sort, status, version ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
[rbatis] [] Args ==> ["2020-11-15T22:18:07.007182300",1,null,null,"12312","123",null,null,null,"1",1,"1"]
Published by zhuxiujia almost 4 years ago
v1.8.19
Published by zhuxiujia almost 4 years ago
v1.8.18
Please replace rbatis_core replace in your project with rbatis::core
# rbatis, must maintain the same versions (required)
rbatis = { version = "1.8.18" }
rbatis-macro-driver = { version = "1.8.18" }
Published by zhuxiujia almost 4 years ago
v1.8.16
#[py_sql(RB, "select * from biz_activity
if arr[0]!=null:
where id in #{ arr[0] }")]
fn py_select1(arr: &Vec<i32>) -> DBExecResult {}
2020-11-13 14:17:15.633393 +08:00 INFO rbatis::plugin::log - [rbatis] [] Query ==> select * from biz_activity where id in ?
2020-11-13 14:17:15.634024 +08:00 INFO rbatis::plugin::log - [rbatis] [] Args ==> [1]
other example
#[test]
fn test_node_run() {
let arg = json!({
"e": [1],
"f": [{
"field": 1
}]
});
let exec_expr = |arg: &serde_json::Value, expr: &str| -> serde_json::Value{
println!("{}", expr.clone());
let box_node = parser::parse(expr, &OptMap::new()).unwrap();
let v = box_node.eval(arg).unwrap();
println!("'{}' -> {}", expr.clone(), &v);
v
};
assert_eq!(exec_expr(&arg, "e[0]"), json!(1));
assert_eq!(exec_expr(&arg, "f[0].field"), json!(1));
assert_eq!(exec_expr(&arg, "f.0.field"), json!(1));
}
Published by zhuxiujia almost 4 years ago
v1.8.15
#[crud_enable]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct BizActivity {
pub id: Option<String>,
pub name: Option<String>,
pub delete_flag: Option<i32>,
}
for example-2(Only the table name is changed, the rest is generated automatically):
#[crud_enable(table_name:biz_activity)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct BizActivity {
pub id: Option<String>,
pub name: Option<String>,
pub delete_flag: Option<i32>,
}
for example-3(Full customization):
#[crud_enable( id_name:id| id_type:String| table_name:biz_activity| table_columns:id,name,delete_flag )]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct BizActivity {
pub id: Option<String>,
pub name: Option<String>,
pub delete_flag: Option<i32>,
}
Published by zhuxiujia almost 4 years ago
v1.8.14
Published by zhuxiujia almost 4 years ago
v1.8.13
Published by zhuxiujia almost 4 years ago
v1.8.12
Published by zhuxiujia almost 4 years ago
v1.8.11
Published by zhuxiujia almost 4 years ago
v1.8.10
Published by zhuxiujia almost 4 years ago
v1.8.9
Published by zhuxiujia almost 4 years ago
v1.8.8
Published by zhuxiujia almost 4 years ago
v1.8.7
Published by zhuxiujia almost 4 years ago
v1.8.6
how to use?
toml add this
rbatis-core = { version = "1.8.6" }
rbatis = { version = "1.8.6", features = ["snowflake"] }
rbatis-macro-driver = { version = "1.8.6", features = ["no_print"] }
code
async_std::task::block_on(async{
let id: i64 = rbatis::plugin::snowflake::async_snowflake_id().await;
println!("{}",id);
});
Published by zhuxiujia almost 4 years ago
v1.8.5
Published by zhuxiujia almost 4 years ago
v1.8.4
Published by zhuxiujia almost 4 years ago
v1.8.3
Published by zhuxiujia almost 4 years ago
En:
中文:
Published by zhuxiujia almost 4 years ago
v1.7.26
Published by zhuxiujia almost 4 years ago
v1.7.25