Skip to main content

AnyQuery

Struct AnyQuery 

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

A query over a table, named by strings.

Implementations§

Source§

impl AnyQuery

Source

pub fn new( schema: Arc<Schema>, table: impl Into<String>, system: System, ) -> Self

All rows of table, for the system system (an app uses System::Client).

Source

pub fn schema(&self) -> &Arc<Schema> ⓘ

The schema the query is built on.

Source

pub fn table(&self) -> &str

The table the query reads.

Source

pub fn ast(&self) -> &Ast

The query’s AST.

Source

pub fn format(&self) -> &Format

How the query’s view shapes its rows.

Source

pub fn system(&self) -> System

The system the query is built for.

Source

pub fn custom_query_id(&self) -> Option<&CustomQueryId>

The name and arguments the query is named by, for a named query.

Source

pub fn invalid(&self) -> Option<&str>

Why the query is invalid: the message JS’s builder throws.

Source

pub fn hash(&self) -> String

The query’s hash as the client and server know it.

Source

pub fn name_and_args(self, name: impl Into<String>, args: Vec<Value>) -> Self

Names the query, as JS’s defineQueries does: the server runs its own query by name with args, and the client syncs what that returns.

Source

pub fn one(self) -> Self

At most one row; the view holds the row or nothing rather than a list.

Source

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

Rows whose field compares to value by op.

Source

pub fn where_param( self, field: impl Into<String>, op: SimpleOperator, param: &StaticParameter, ) -> Self

Rows whose field compares to a value of the context by op.

Source

pub fn where_expr( self, factory: impl FnOnce(&ExpressionBuilder<'_>) -> Condition, ) -> Self

Rows that match the condition factory builds.

Source

pub fn where_condition(self, condition: Condition) -> Self

Rows that match condition, and any earlier where.

Source

pub fn where_exists( self, relationship: &str, options: ExistsOptions, sub: impl FnOnce(AnyQuery) -> AnyQuery, ) -> Self

Rows with a related row in relationship that sub matches.

Source

pub fn start(self, row: Object, inclusive: bool) -> Self

Starts after the row with these columns, or at it when inclusive.

Source

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

At most limit rows.

Source

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

Orders the rows by field, after any earlier order_by; the primary key breaks ties.

Source

pub fn related( self, relationship: &str, sub: impl FnOnce(AnyQuery) -> AnyQuery, ) -> Self

Includes the rows of relationship, as sub shapes them.

Source

pub fn count(self) -> Self

The number of rows: a query of one value rather than rows.

Source

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

The sum of field’s non-null values; null when there are none.

Source

pub fn sum_json( self, column: impl Into<String>, path: Vec<JsonPathSegment>, ) -> Self

The sum of the numbers at a JSON path in the json column column.

Source

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

The average of field’s non-null values; null when there are none.

Source

pub fn avg_json( self, column: impl Into<String>, path: Vec<JsonPathSegment>, ) -> Self

Reduces the query to the average of the numbers at path in the JSON column.

Source

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

The least of field’s non-null values; null when there are none.

Source

pub fn min_json( self, column: impl Into<String>, path: Vec<JsonPathSegment>, ) -> Self

The least number or string at a JSON path; numbers sort first.

Source

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

The greatest of field’s non-null values; null when there are none.

Source

pub fn max_json( self, column: impl Into<String>, path: Vec<JsonPathSegment>, ) -> Self

Reduces the query to the greatest value at path in the JSON column.

Source

pub fn distinct(self, columns: Vec<String>) -> Self

The distinct combinations of columns’ values, as SELECT DISTINCT: rows of those columns. count() after it counts the combinations.

Source

pub fn group_by(self, columns: Vec<String>) -> AnyGroupedQuery

Groups the rows by columns, as GROUP BY; an aggregate of the result gives one row per group, with the value under the function’s name.

Trait Implementations§

Source§

impl Clone for AnyQuery

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AnyQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.