Skip to main content

QueryBuilder

Struct QueryBuilder 

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

Fluent, programmatic construction of a QuerySpec — the typed counterpart of the WHERE-clause text parsed by super::parser::parse_query. SELECT/FROM/JOIN/MATCH from ADR-0009 are a separate, larger piece and still not covered by either front.

Implementations§

Source§

impl QueryBuilder

Source

pub fn new() -> Self

Source

pub fn where( self, field: impl Into<String>, op: ComparisonOp, value: Value, ) -> Self

Source

pub fn where_any(self, build: impl FnOnce(&mut PredicateGroupBuilder)) -> Self

Source

pub fn where_all(self, build: impl FnOnce(&mut PredicateGroupBuilder)) -> Self

Source

pub fn search(self, text: impl Into<String>, mode: SearchMode) -> Self

Source

pub fn order_by( self, field: impl Into<String>, direction: SortDirection, ) -> Self

Sets the sort key. One key only, and a second call replaces the first — the TS QueryBuilder.orderBy this mirrors keeps a single key too.

Source

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

Source

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

Source

pub fn count(self) -> Self

Source

pub fn sum(self, field: impl Into<String>) -> Self

Source

pub fn avg(self, field: impl Into<String>) -> Self

Source

pub fn min(self, field: impl Into<String>) -> Self

Source

pub fn max(self, field: impl Into<String>) -> Self

Source

pub fn group_by(self, field: impl Into<String>) -> Self

Source

pub fn spec(self) -> QuerySpec

Source

pub fn build_aggregate(self) -> (QuerySpec, AggregateSpec)

Splits the builder into its QuerySpec (predicates/search) and the AggregateSpec accumulated by count/sum/avg/min/max — the two halves Table::aggregate expects.

Trait Implementations§

Source§

impl Default for QueryBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.