Struct rbatis::wrapper::Wrapper [−][src]
pub struct Wrapper {
pub driver_type: DriverType,
pub dml: String,
pub sql: String,
pub args: Vec<Bson>,
pub formats: HashMap<String, fn(arg: &str) -> String>,
}
Expand description
The packing/Wrapper of the SQL SQL passed into the Wrapper keep the keyword uppercase
for Example: let w = Wrapper::new(&DriverType::Mysql) .push_sql(“id == 1”) .eq(“id”, 1) .and() .ne(“id”, 1) .and() .in_array(“id”, &[1, 2, 3]) .in_(“id”, &[1, 2, 3]) .r#in(“id”, &[1, 2, 3]) .and() .not_in(“id”, &[1, 2, 3]) .and() .like(“name”, 1) .or() .not_like(“name”, “asdf”) .and() .between(“create_time”, “2020-01-01 00:00:00”, “2020-12-12 00:00:00”) .group_by(&[“id”]) .order_by(true, &[“id”, “name”]) ;
Fields
driver_type: DriverType
dml: String
sql: String
args: Vec<Bson>
formats: HashMap<String, fn(arg: &str) -> String>
Implementations
link left Wrapper to this Wrapper for Example: let w = Wrapper::new(&DriverType::Postgres).push_sql(“(”).eq(“a”, “1”).push_sql(“)”); let w2 = Wrapper::new(&DriverType::Postgres).eq(“b”, “2”) .and() .push_wrapper(w); println!(“sql:{:?}”, w2.sql.as_str()); // sql:“b = ? and (a = ?)” println!(“arg:{:?}”, w2.args.clone()); // arg:[String(“2”), String(“1”)]
do method,if test is true for example: let arg = 1; wrapper.do_if(true, |w| w.eq(“id”))
pub fn do_if_else<'s, F>(
self,
test: bool,
method_if: F,
method_else: fn(_: Self) -> Self
) -> Self where
F: FnOnce(Self) -> Self,
pub fn do_if_else<'s, F>(
self,
test: bool,
method_if: F,
method_else: fn(_: Self) -> Self
) -> Self where
F: FnOnce(Self) -> Self,
do method,if test is true for example: let arg = 1; wrapper.do_if(true, |w| w.eq(“id”),|w|w)
match cases
for example:
let p = Option::
arg: JsonObject or struct{} or map[String,**]
format column
equal for example: eq(“a”,1) “ a = 1 “
gen sql: * in (,,*)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Wrapper
impl UnwindSafe for Wrapper
Blanket Implementations
Mutably borrows from an owned value. Read more