Skip to main content

QueryBuilder

Struct QueryBuilder 

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

Builder used inside a schema crate. It is deliberately stateful: the closure describes one plan, then finish() returns plain serializable data.

Implementations§

Source§

impl QueryBuilder

Source

pub fn new(name: impl Into<String>, doc: impl Into<String>) -> Self

Source

pub fn from<M: QueryModel>(&mut self) -> M::Fields

Source

pub fn filter(&mut self, expr: BoolExpr)

Source

pub fn group_by<T>(&mut self, field: &FieldExpr<T>)

Source

pub fn field<T>( &mut self, name: impl Into<String>, field: &FieldExpr<T>, ) -> ColumnHandle<'_>

Source

pub fn count(&mut self, name: impl Into<String>) -> ColumnHandle<'_>

Source

pub fn count_of<T>( &mut self, name: impl Into<String>, field: &FieldExpr<T>, ) -> ColumnHandle<'_>

Count rows where the expression is non-null — the SQL COUNT(col) semantics; with a LEFT join this is how “0 related” stays 0.

Source

pub fn count_distinct<T>( &mut self, name: impl Into<String>, field: &FieldExpr<T>, ) -> ColumnHandle<'_>

Source

pub fn sum<T>( &mut self, name: impl Into<String>, field: &FieldExpr<T>, ) -> ColumnHandle<'_>

Source

pub fn min<T>( &mut self, name: impl Into<String>, field: &FieldExpr<T>, ) -> ColumnHandle<'_>

Source

pub fn max<T>( &mut self, name: impl Into<String>, field: &FieldExpr<T>, ) -> ColumnHandle<'_>

Source

pub fn follow_in<M: QueryModel>( &mut self, anchor: u32, field: impl Into<String>, required: bool, ) -> M::Fields

JOIN: bind records of M whose OWN link field field points at the anchor binding’s record (SQL: FROM anchor JOIN M ON M.field = anchor). required: false is a LEFT join — anchor rows without a match keep one row with the M binding absent. The field name is a string until slice 3’s typed EdgeExpr; the registry gate validates it at emission.

Source

pub fn follow_out<M: QueryModel>( &mut self, anchor: u32, field: impl Into<String>, required: bool, ) -> M::Fields

JOIN along a link field ON THE ANCHOR pointing out at records of M.

Source

pub fn order_by<T>(&mut self, field: &FieldExpr<T>, direction: SortDirection)

Source

pub fn order_by_column(&mut self, name: &str, direction: SortDirection)

Order by an output column’s expression (aggregates included).

Source

pub fn limit(&mut self, limit: usize)

Source

pub fn finish(self) -> QueryDecl

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