Struct QueryExample

Source
pub struct QueryExample;
Expand description

这个模块提供了QueryWrapper功能,用于构建SQL查询条件

§示例

use next_web_common::query::query_wrapper::{QueryWrapper, OrderDirection};
 
// 创建一个简单的查询
let query = QueryWrapper::new()
    .eq("name", "张三")
    .gt("age", "18")
    .build_sql("users");
 
// 创建一个复杂的查询
let complex_query = QueryWrapper::new()
    .eq("status", "active")
    .or()
    .nested(|q| q.eq("role", "admin").gt("level", "5"))
    .order_by_desc("created_at")
    .limit(10)
    .offset(20)
    .build_sql("users");
 
// 使用IN条件
let in_query = QueryWrapper::new()
    .r#in("id", vec!["1", "2", "3"])
    .build_sql("users");
 
// 使用BETWEEN条件
let between_query = QueryWrapper::new()
    .between("age", "18", "30")
    .build_sql("users");
 
// 使用LIKE条件
let like_query = QueryWrapper::new()
    .like("name", "张")
    .build_sql("users");
 
// 使用GROUP BY和HAVING
let group_query = QueryWrapper::new()
    .select(vec!["department", "COUNT(*) as count"])
    .group_by(vec!["department"])
    .having("COUNT(*) > 5")
    .build_sql("employees");

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.