[][src]Struct rbatis::wrapper::Wrapper

pub struct Wrapper {
    pub driver_type: DriverType,
    pub sql: String,
    pub args: Vec<Value>,
    pub error: Option<Error>,
    pub checked: bool,
}

you can serialize to JSON, and Clone, Debug use json rpc send this Wrapper to server

for Example: let w = Wrapper::new(&DriverType::Mysql) .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"]) .check().unwrap();

Fields

driver_type: DriverTypesql: Stringargs: Vec<Value>error: Option<Error>checked: bool

Implementations

impl Wrapper[src]

pub fn new(driver_type: &DriverType) -> Self[src]

pub fn from(driver_type: &DriverType, sql: &str, args: &Vec<Value>) -> Self[src]

pub fn check(&mut self) -> Result<Wrapper, Error>[src]

pub fn push_wrapper(&mut self, arg: &Wrapper) -> &mut Self[src]

link left Wrapper to this Wrapper for Example: let w = Wrapper::new(&DriverType::Postgres).push_sql("(").eq("a", "1").push_sql(")").check().unwrap(); let w2 = Wrapper::new(&DriverType::Postgres).eq("b", "2") .and() .push_wrapper(&w) .check().unwrap(); println!("sql:{:?}", w2.sql.as_str()); // sql:"b = ? AND (a = ?)" println!("arg:{:?}", w2.args.clone()); // arg:[String("2"), String("1")]

pub fn push<T>(&mut self, sql: &str, args: &[T]) -> &mut Self where
    T: Serialize
[src]

push sql,args into self

pub fn do_if<'s, F>(&'s mut self, test: bool, method: F) -> &'s mut Self where
    F: FnOnce(&'s mut Self) -> &'s mut Self, 
[src]

do method,if test is true for example: let arg = 1; wrapper.if_do(true, |w,arg| w.eq("id", arg))

pub fn do_match<'s, F>(
    &'s mut self,
    cases: &'s [Case],
    default: F
) -> &'s mut Self where
    F: FnOnce(&'s mut Self) -> &'s mut Self, 
[src]

match cases for example: let p = Option::::Some(1); let w = Wrapper::new(&DriverType::Postgres) .do_match(&[ Case::new(p.is_some(),|w| w), Case::new(p.is_none(),|w| w), ], |w| w) .check().unwrap();

pub fn set_sql(&mut self, sql: &str) -> &mut Self[src]

pub fn push_sql(&mut self, sql: &str) -> &mut Self[src]

pub fn set_args<T>(&mut self, args: &[T]) -> &mut Self where
    T: Serialize
[src]

pub fn push_arg<T>(&mut self, arg: T) -> &mut Self where
    T: Serialize
[src]

pub fn pop_arg(&mut self) -> &mut Self[src]

pub fn and(&mut self) -> &mut Self[src]

link wrapper sql, if end with where , do nothing

pub fn or(&mut self) -> &mut Self[src]

link wrapper sql, if end with where , do nothing

pub fn having(&mut self, sql_having: &str) -> &mut Self[src]

pub fn all_eq<T>(&mut self, arg: T) -> &mut Self where
    T: Serialize
[src]

arg: JsonObject or struct{} or map[String,**]

pub fn eq<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

equal for example: eq("a",1) " a = 1 "

pub fn ne<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

not equal

pub fn order_by(&mut self, is_asc: bool, columns: &[&str]) -> &mut Self[src]

pub fn group_by(&mut self, columns: &[&str]) -> &mut Self[src]

pub fn gt<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

sql: column > obj

pub fn ge<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

sql: column >= obj

pub fn lt<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

sql: column < obj

pub fn le<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

sql: column <= obj

pub fn between<T>(&mut self, column: &str, min: T, max: T) -> &mut Self where
    T: Serialize
[src]

pub fn not_between<T>(&mut self, column: &str, min: T, max: T) -> &mut Self where
    T: Serialize
[src]

pub fn like<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

pub fn like_left<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

pub fn like_right<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

pub fn not_like<T>(&mut self, column: &str, obj: T) -> &mut Self where
    T: Serialize
[src]

pub fn is_null(&mut self, column: &str) -> &mut Self[src]

pub fn is_not_null(&mut self, column: &str) -> &mut Self[src]

pub fn in_array<T>(&mut self, column: &str, obj: &[T]) -> &mut Self where
    T: Serialize
[src]

gen sql: * in (,,*)

pub fn in_<T>(&mut self, column: &str, obj: &[T]) -> &mut Self where
    T: Serialize
[src]

gen sql: * in (,,*)

pub fn in<T>(&mut self, column: &str, obj: &[T]) -> &mut Self where
    T: Serialize
[src]

gen sql: * in (,,*)

pub fn not_in<T>(&mut self, column: &str, obj: &[T]) -> &mut Self where
    T: Serialize
[src]

pub fn trim_and(&mut self) -> &mut Self[src]

pub fn trim_or(&mut self) -> &mut Self[src]

Trait Implementations

impl Clone for Wrapper[src]

impl Debug for Wrapper[src]

impl<'de> Deserialize<'de> for Wrapper[src]

impl Serialize for Wrapper[src]

Auto Trait Implementations

impl RefUnwindSafe for Wrapper

impl Send for Wrapper

impl Sync for Wrapper

impl Unpin for Wrapper

impl UnwindSafe for Wrapper

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,