pub struct QueryWrapper {
pub inner: AbstractWrapper,
pub func: FuncSegments,
/* private fields */
}Expand description
Query wrapper with String column names.
Mirrors Java com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<T>.
§Example
ⓘ
use rbatis_plus::core::conditions::query::QueryWrapper;
let w = QueryWrapper::new()
.eq("name", "Alice")
.ge("age", 18)
.like("email", "gmail")
.order_by_desc("create_time");
let sql = w.build_select_sql("sys_user");
// SELECT * FROM sys_user WHERE name = 'Alice' AND age >= 18 AND email LIKE '%gmail%' ORDER BY create_time DESCFields§
§inner: AbstractWrapper§func: FuncSegmentsImplementations§
Source§impl QueryWrapper
impl QueryWrapper
pub fn new() -> QueryWrapper
Sourcepub fn select(&mut self, columns: &[&str]) -> &mut QueryWrapper
pub fn select(&mut self, columns: &[&str]) -> &mut QueryWrapper
Set the SELECT columns. Overwrites previous selection.
设置查询字段
Sourcepub fn build_select_sql(&self, table_name: &str) -> String
pub fn build_select_sql(&self, table_name: &str) -> String
Build the SELECT SQL for the given table.
Sourcepub fn build_count_sql(&self, table_name: &str) -> String
pub fn build_count_sql(&self, table_name: &str) -> String
Build a COUNT SQL for the given table (for pagination).
Source§impl QueryWrapper
Legacy compatibility entry point — absorbs the rbatis-wrapper crate API.
impl QueryWrapper
Legacy compatibility entry point — absorbs the rbatis-wrapper crate API.
In new code prefer QueryWrapper directly; this module provides
the same query(), get_one(), delete(), and page() async methods
that rbatis-wrapper exposed, now backed by the full QueryWrapper.
Sourcepub async fn query<T>(
&self,
rb: &(dyn Executor + 'static),
table_name: &str,
) -> Result<Vec<T>, Error>where
T: Serialize + DeserializeOwned,
pub async fn query<T>(
&self,
rb: &(dyn Executor + 'static),
table_name: &str,
) -> Result<Vec<T>, Error>where
T: Serialize + DeserializeOwned,
Execute the query and return a list of entities.
执行查询返回列表
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Compare for QueryWrapper
impl Compare for QueryWrapper
Source§fn eq(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
fn eq(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
column = value Read moreSource§fn if_eq(
&mut self,
condition: bool,
column: &str,
value: impl Into<Value>,
) -> &mut QueryWrapper
fn if_eq( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut QueryWrapper
Conditional eq — only applies when
condition is true.fn if_ne( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut QueryWrapper
Source§fn gt(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
fn gt(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
column > value Read morefn if_gt( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut QueryWrapper
Source§fn ge(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
fn ge(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
column >= value Read morefn if_ge( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut QueryWrapper
Source§fn lt(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
fn lt(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
column < value Read morefn if_lt( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut QueryWrapper
Source§fn le(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
fn le(&mut self, column: &str, value: impl Into<Value>) -> &mut QueryWrapper
column <= value Read morefn if_le( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut QueryWrapper
Source§fn between(
&mut self,
column: &str,
val1: impl Into<Value>,
val2: impl Into<Value>,
) -> &mut QueryWrapper
fn between( &mut self, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut QueryWrapper
column BETWEEN val1 AND val2 Read morefn if_between( &mut self, condition: bool, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut QueryWrapper
Source§fn not_between(
&mut self,
column: &str,
val1: impl Into<Value>,
val2: impl Into<Value>,
) -> &mut QueryWrapper
fn not_between( &mut self, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut QueryWrapper
column NOT BETWEEN val1 AND val2 Read morefn if_not_between( &mut self, condition: bool, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut QueryWrapper
Source§fn eq_or_is_null(
&mut self,
column: &str,
value: impl Into<Value>,
) -> &mut QueryWrapper
fn eq_or_is_null( &mut self, column: &str, value: impl Into<Value>, ) -> &mut QueryWrapper
column = value OR column IS NULL (when value is null, just IS NULL) 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
Source§impl Func for QueryWrapper
impl Func for QueryWrapper
Source§fn like(&mut self, column: &str, value: &str) -> &mut QueryWrapper
fn like(&mut self, column: &str, value: &str) -> &mut QueryWrapper
column LIKE '%value%' Read morefn if_like( &mut self, condition: bool, column: &str, value: &str, ) -> &mut QueryWrapper
Source§fn not_like(&mut self, column: &str, value: &str) -> &mut QueryWrapper
fn not_like(&mut self, column: &str, value: &str) -> &mut QueryWrapper
column NOT LIKE '%value%' Read morefn if_not_like( &mut self, condition: bool, column: &str, value: &str, ) -> &mut QueryWrapper
Source§fn like_left(&mut self, column: &str, value: &str) -> &mut QueryWrapper
fn like_left(&mut self, column: &str, value: &str) -> &mut QueryWrapper
column LIKE '%value' Read morefn if_like_left( &mut self, condition: bool, column: &str, value: &str, ) -> &mut QueryWrapper
Source§fn like_right(&mut self, column: &str, value: &str) -> &mut QueryWrapper
fn like_right(&mut self, column: &str, value: &str) -> &mut QueryWrapper
column LIKE 'value%' Read morefn if_like_right( &mut self, condition: bool, column: &str, value: &str, ) -> &mut QueryWrapper
fn if_is_null(&mut self, condition: bool, column: &str) -> &mut QueryWrapper
Source§fn is_not_null(&mut self, column: &str) -> &mut QueryWrapper
fn is_not_null(&mut self, column: &str) -> &mut QueryWrapper
column IS NOT NULL Read morefn if_is_not_null(&mut self, condition: bool, column: &str) -> &mut QueryWrapper
Source§fn in_values(&mut self, column: &str, values: Vec<Value>) -> &mut QueryWrapper
fn in_values(&mut self, column: &str, values: Vec<Value>) -> &mut QueryWrapper
column IN (v1, v2, ...) Read morefn if_in_values( &mut self, condition: bool, column: &str, values: Vec<Value>, ) -> &mut QueryWrapper
Source§fn not_in(&mut self, column: &str, values: Vec<Value>) -> &mut QueryWrapper
fn not_in(&mut self, column: &str, values: Vec<Value>) -> &mut QueryWrapper
column NOT IN (v1, v2, ...) Read morefn if_not_in( &mut self, condition: bool, column: &str, values: Vec<Value>, ) -> &mut QueryWrapper
Source§fn in_sql(&mut self, column: &str, sql: &str) -> &mut QueryWrapper
fn in_sql(&mut self, column: &str, sql: &str) -> &mut QueryWrapper
column IN (subquery_sql) Read moreSource§fn not_in_sql(&mut self, column: &str, sql: &str) -> &mut QueryWrapper
fn not_in_sql(&mut self, column: &str, sql: &str) -> &mut QueryWrapper
column NOT IN (subquery_sql) Read moreSource§fn group_by(&mut self, columns: &[&str]) -> &mut QueryWrapper
fn group_by(&mut self, columns: &[&str]) -> &mut QueryWrapper
GROUP BY col1, col2, ... Read moreSource§fn order_by(&mut self, column: &str, is_asc: bool) -> &mut QueryWrapper
fn order_by(&mut self, column: &str, is_asc: bool) -> &mut QueryWrapper
ORDER BY col ASC/DESC Read morefn order_by_asc(&mut self, column: &str) -> &mut QueryWrapper
fn order_by_desc(&mut self, column: &str) -> &mut QueryWrapper
Source§impl Join for QueryWrapper
impl Join for QueryWrapper
Source§fn not_exists(&mut self, sql: &str) -> &mut QueryWrapper
fn not_exists(&mut self, sql: &str) -> &mut QueryWrapper
NOT EXISTS 子查询。 Read more
Source§fn last(&mut self, sql: &str) -> &mut QueryWrapper
fn last(&mut self, sql: &str) -> &mut QueryWrapper
Source§impl Nested for QueryWrapper
impl Nested for QueryWrapper
Source§fn or(&mut self) -> &mut QueryWrapper
fn or(&mut self) -> &mut QueryWrapper
Bare
OR connector — changes the next condition’s connector to OR. Read moreSource§fn and_group(&mut self, inner_sql: &str) -> &mut QueryWrapper
fn and_group(&mut self, inner_sql: &str) -> &mut QueryWrapper
AND (...) — adds a grouped AND block. Read moreSource§fn or_group(&mut self, inner_sql: &str) -> &mut QueryWrapper
fn or_group(&mut self, inner_sql: &str) -> &mut QueryWrapper
OR (...) — adds a grouped OR block. Read moreAuto Trait Implementations§
impl Freeze for QueryWrapper
impl RefUnwindSafe for QueryWrapper
impl Send for QueryWrapper
impl Sync for QueryWrapper
impl Unpin for QueryWrapper
impl UnsafeUnpin 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