pub struct QueryWrapper { /* private fields */ }Expand description
like mybatis plus for example:
let count = QueryWrapper::new()
.custom_sql("select count(*) from member")
.get_one::<u64>(&RB, "")
.await?;
println!("count: {:?}", count);
#[derive(serde::Deserialize, serde::Serialize, Debug)]
struct Member {
id: u64,
email: Option<String>
}
let member = QueryWrapper::new()
.eq("id", 7386)
.get_one::<Member>(&RB, "member")
.await?;
println!("member: {:?}", member);
Ok(Json(json!({
"code": 0,
"data": member,
"count": count,
})))Implementations§
Source§impl QueryWrapper
impl QueryWrapper
pub fn new() -> Self
pub fn eq<T: ToString>(self, column: &str, value: T) -> Self
pub fn ne<T: ToString>(self, column: &str, value: T) -> Self
pub fn gt<T: ToString>(self, column: &str, value: T) -> Self
pub fn lt<T: ToString>(self, column: &str, value: T) -> Self
pub fn like(self, column: &str, value: &str) -> Self
pub fn select(self, columns: Vec<&str>) -> Self
pub fn order_by(self, column: &str, asc: bool) -> Self
pub fn limit(&mut self, limit: u64) -> &mut Self
pub fn offset(&mut self, offset: u64) -> &mut Self
pub fn custom_sql(self, sql: &str) -> Self
pub fn inner_join(self, table: &str, on_condition: &str) -> Self
pub fn left_join(self, table: &str, on_condition: &str) -> Self
pub fn right_join(self, table: &str, on_condition: &str) -> Self
pub fn build_sql(&self, table_name: &str) -> String
pub async fn query<T>(
&self,
rb: &RBatis,
table_name: &str,
) -> Result<Vec<T>, Error>where
T: Serialize + for<'de> Deserialize<'de>,
pub async fn get_one<T>(
&self,
rb: &RBatis,
table_name: &str,
) -> Result<Option<T>, Error>where
T: Serialize + for<'de> Deserialize<'de>,
pub async fn delete(self, rb: &RBatis, table_name: &str) -> Result<u64, Error>
pub async fn page<T>(
&self,
rb: &RBatis,
table_name: &str,
page_no: u64,
page_size: u64,
) -> Result<Page<T>, Error>where
T: Serialize + for<'de> Deserialize<'de>,
Trait Implementations§
Source§impl Clone for QueryWrapper
impl Clone for QueryWrapper
Source§fn clone(&self) -> QueryWrapper
fn clone(&self) -> QueryWrapper
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueryWrapper
impl Debug for QueryWrapper
Source§impl Default for QueryWrapper
impl Default for QueryWrapper
Source§fn default() -> QueryWrapper
fn default() -> QueryWrapper
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for QueryWrapper
impl RefUnwindSafe for QueryWrapper
impl Send for QueryWrapper
impl Sync for QueryWrapper
impl Unpin for QueryWrapper
impl UnwindSafe for QueryWrapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more