Skip to main content

QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder { /* private fields */ }
Expand description

查询构建器

Implementations§

Source§

impl QueryBuilder

Source

pub fn new(table: String, engine: Arc<RwLock<MemoryEngine>>) -> Self

Source

pub fn eq(self, field: &str, value: DbValue) -> Self

Source

pub fn ne(self, field: &str, value: DbValue) -> Self

Source

pub fn lt(self, field: &str, value: DbValue) -> Self

Source

pub fn le(self, field: &str, value: DbValue) -> Self

Source

pub fn gt(self, field: &str, value: DbValue) -> Self

Source

pub fn ge(self, field: &str, value: DbValue) -> Self

Source

pub fn in_list(self, field: &str, values: Vec<DbValue>) -> Self

Source

pub fn contains(self, field: &str, value: &str) -> Self

Source

pub fn and(self, other: QueryBuilder) -> Self

Source

pub fn order_by(self, field: &str, order: Order) -> Self

Source

pub fn limit(self, limit: usize) -> Self

Source

pub fn offset(self, offset: usize) -> Self

Source

pub fn inner_join( self, right_table: &str, left_field: &str, right_field: &str, ) -> Self

Source

pub fn left_join( self, right_table: &str, left_field: &str, right_field: &str, ) -> Self

Source

pub fn right_join( self, right_table: &str, left_field: &str, right_field: &str, ) -> Self

Source

pub fn full_join( self, right_table: &str, left_field: &str, right_field: &str, ) -> Self

Source

pub fn select(self, columns: &[&str]) -> Self

Source

pub fn count(self) -> Self

COUNT(*) - 统计行数

Source

pub fn count_column(self, column: &str) -> Self

COUNT(column) - 统计非 NULL 行数

Source

pub fn sum(self, column: &str) -> Self

SUM(column) - 求和

Source

pub fn avg(self, column: &str) -> Self

AVG(column) - 平均值

Source

pub fn max(self, column: &str) -> Self

MAX(column) - 最大值

Source

pub fn min(self, column: &str) -> Self

MIN(column) - 最小值

Source

pub fn alias(self, name: &str) -> Self

设置聚合结果别名

Source

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

GROUP BY 子句

Source

pub fn having_eq(self, value: DbValue) -> Self

HAVING 子句 - 等于

Source

pub fn having_ne(self, value: DbValue) -> Self

HAVING 子句 - 不等于

Source

pub fn having_gt(self, value: DbValue) -> Self

HAVING 子句 - 大于

Source

pub fn having_ge(self, value: DbValue) -> Self

HAVING 子句 - 大于等于

Source

pub fn having_lt(self, value: DbValue) -> Self

HAVING 子句 - 小于

Source

pub fn having_le(self, value: DbValue) -> Self

HAVING 子句 - 小于等于

Source

pub fn execute(self) -> DbResult<Vec<Row>>

执行查询

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.