Skip to main content

LinqQuery

Struct LinqQuery 

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

LINQ 风格查询构建器

Implementations§

Source§

impl LinqQuery

Source

pub fn from(table: &str) -> Self

FROM 子句 — 指定表名

Source

pub fn select(self, cols: Vec<&str>) -> Self

SELECT 子句 — 指定列

Source

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

WHERE 等于条件

Source

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

WHERE 不等于条件

Source

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

WHERE 大于条件

Source

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

WHERE 小于条件

Source

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

WHERE 大于等于条件

Source

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

WHERE 小于等于条件

Source

pub fn where_like(self, field: &str, pattern: Value) -> Self

WHERE LIKE 条件

Source

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

WHERE IN 条件

Source

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

WHERE IS NULL

Source

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

WHERE IS NOT NULL

Source

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

ORDER BY 升序

Source

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

ORDER BY 降序

Source

pub fn take(self, n: usize) -> Self

TAKE — 取前 N 条(等价于 LIMIT)

Source

pub fn skip(self, n: usize) -> Self

SKIP — 跳过 N 条(等价于 OFFSET)

Source

pub fn distinct(self) -> Self

DISTINCT — 去重

Source

pub fn group_by(self, cols: Vec<&str>) -> Self

GROUP BY — 分组

Source

pub fn build(&self) -> String

构建 SQL

Source

pub fn params(&self) -> &[Value]

获取参数

Source

pub fn build_count(&self) -> String

构建 COUNT 查询

Source

pub fn build_exists(&self) -> String

构建 EXISTS 查询

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more