[−][src]Struct rbatis::wrapper::Wrapper
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: DriverType
sql: String
args: 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]
T: Serialize,
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]
F: FnOnce(&'s mut Self) -> &'s mut Self,
do method,if test is true for example: let arg = 1; wrapper.if_do(true, |w| w.eq("id"))
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]
&'s mut self,
cases: &'s [Case],
default: F
) -> &'s mut Self where
F: FnOnce(&'s mut Self) -> &'s mut Self,
match cases
for example:
let p = Option::
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]
T: Serialize,
pub fn push_arg<T>(&mut self, arg: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
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]
T: Serialize,
arg: JsonObject or struct{} or map[String,**]
pub fn eq<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
equal for example: eq("a",1) " a = 1 "
pub fn ne<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
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]
T: Serialize,
sql: column > obj
pub fn ge<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
sql: column >= obj
pub fn lt<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
sql: column < obj
pub fn le<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
sql: column <= obj
pub fn between<T>(&mut self, column: &str, min: T, max: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
pub fn not_between<T>(&mut self, column: &str, min: T, max: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
pub fn like<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
pub fn like_left<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
pub fn like_right<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
pub fn not_like<T>(&mut self, column: &str, obj: T) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
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]
T: Serialize,
gen sql: * in (,,*)
pub fn in_<T>(&mut self, column: &str, obj: &[T]) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
gen sql: * in (,,*)
pub fn in<T>(&mut self, column: &str, obj: &[T]) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
gen sql: * in (,,*)
pub fn not_in<T>(&mut self, column: &str, obj: &[T]) -> &mut Self where
T: Serialize,
[src]
T: Serialize,
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,