pub struct Query<R, T = Vec<R>> { /* private fields */ }Expand description
A query over the rows of R’s table that materializes to a T: the
rows (Vec<R>), the row of one() (Option<R>), or an aggregate.
Implementations§
Source§impl<R: ZeroRow, T> Query<R, T>
impl<R: ZeroRow, T> Query<R, T>
Sourcepub fn where_eq<V: ZeroValue>(self, column: Column<R, V>, value: V) -> Self
pub fn where_eq<V: ZeroValue>(self, column: Column<R, V>, value: V) -> Self
Rows whose column equals value; with null, IS.
Sourcepub fn where_<V: ZeroValue>(
self,
column: Column<R, V>,
op: SimpleOperator,
value: V,
) -> Self
pub fn where_<V: ZeroValue>( self, column: Column<R, V>, op: SimpleOperator, value: V, ) -> Self
Rows whose column compares to value by op.
Sourcepub fn where_in<V: ZeroValue>(
self,
column: Column<R, V>,
op: SimpleOperator,
values: Vec<V>,
) -> Self
pub fn where_in<V: ZeroValue>( self, column: Column<R, V>, op: SimpleOperator, values: Vec<V>, ) -> Self
Rows whose column is IN or NOT IN values.
Sourcepub fn where_param<V>(
self,
column: Column<R, V>,
op: SimpleOperator,
param: &StaticParameter,
) -> Self
pub fn where_param<V>( self, column: Column<R, V>, op: SimpleOperator, param: &StaticParameter, ) -> Self
Rows whose column compares to a value of the context by op.
Sourcepub fn where_condition(self, condition: Condition) -> Self
pub fn where_condition(self, condition: Condition) -> Self
Rows that match condition, and any earlier where.
Sourcepub fn where_expr(
self,
factory: impl FnOnce(&RowExpression<'_, '_, R>) -> Condition,
) -> Self
pub fn where_expr( self, factory: impl FnOnce(&RowExpression<'_, '_, R>) -> Condition, ) -> Self
Rows that match the condition factory builds from the row’s
expression: its JSON paths, exists, and and, or and not.
Sourcepub fn where_exists<D: ZeroRow>(
self,
relationship: Relationship<R, D>,
options: ExistsOptions,
sub: impl FnOnce(Query<D>) -> Query<D>,
) -> Self
pub fn where_exists<D: ZeroRow>( self, relationship: Relationship<R, D>, options: ExistsOptions, sub: impl FnOnce(Query<D>) -> Query<D>, ) -> Self
Rows with a related row in relationship that sub matches.
Fills relationship of each row, or, when sub ends in an
aggregate, sets the row’s aggregate of it: related(Issue::COMMENTS, |q| q.count()) gives aggregates.count(Issue::COMMENTS).
Sourcepub fn order_by<V>(self, column: Column<R, V>, direction: Direction) -> Self
pub fn order_by<V>(self, column: Column<R, V>, direction: Direction) -> Self
Orders the rows by column, after any earlier order_by; the primary
key breaks ties.
Sourcepub fn start(self, row: &R, inclusive: bool) -> Self
pub fn start(self, row: &R, inclusive: bool) -> Self
Starts after row, or at it when inclusive.
Sourcepub fn start_values(
self,
values: Vec<(ColumnRef<R>, Value)>,
inclusive: bool,
) -> Self
pub fn start_values( self, values: Vec<(ColumnRef<R>, Value)>, inclusive: bool, ) -> Self
Starts after the row with these column values, or at it when
inclusive: a cursor that holds only the columns the query orders
by.
Sourcepub fn count(self) -> Query<R, i64>
pub fn count(self) -> Query<R, i64>
Reduces the query to a count of the rows left after where, start
and limit.
Sourcepub fn sum<V: NumericZeroValue>(
self,
column: Column<R, V>,
) -> Query<R, Option<f64>>
pub fn sum<V: NumericZeroValue>( self, column: Column<R, V>, ) -> Query<R, Option<f64>>
The sum of a number column; None over no rows.
Sourcepub fn sum_json<V>(
self,
column: Column<R, V>,
path: Vec<JsonPathSegment>,
) -> Query<R, Option<f64>>
pub fn sum_json<V>( self, column: Column<R, V>, path: Vec<JsonPathSegment>, ) -> Query<R, Option<f64>>
The sum of the numbers at path in a json column. A missing path,
or a value that isn’t a number, is skipped.
Sourcepub fn avg<V: NumericZeroValue>(
self,
column: Column<R, V>,
) -> Query<R, Option<f64>>
pub fn avg<V: NumericZeroValue>( self, column: Column<R, V>, ) -> Query<R, Option<f64>>
The average of a number column; None over no rows.
Sourcepub fn avg_json<V>(
self,
column: Column<R, V>,
path: Vec<JsonPathSegment>,
) -> Query<R, Option<f64>>
pub fn avg_json<V>( self, column: Column<R, V>, path: Vec<JsonPathSegment>, ) -> Query<R, Option<f64>>
Reduces the query to the average of the numbers at path in the JSON
column.
Sourcepub fn min<V: OrderedZeroValue>(
self,
column: Column<R, V>,
) -> Query<R, Option<V::Unwrapped>>
pub fn min<V: OrderedZeroValue>( self, column: Column<R, V>, ) -> Query<R, Option<V::Unwrapped>>
The least value of a number or string column; None over no rows.
Sourcepub fn min_json<V>(
self,
column: Column<R, V>,
path: Vec<JsonPathSegment>,
) -> Query<R, Option<Value>>
pub fn min_json<V>( self, column: Column<R, V>, path: Vec<JsonPathSegment>, ) -> Query<R, Option<Value>>
Reduces the query to the least value at path in the JSON column.
Sourcepub fn max<V: OrderedZeroValue>(
self,
column: Column<R, V>,
) -> Query<R, Option<V::Unwrapped>>
pub fn max<V: OrderedZeroValue>( self, column: Column<R, V>, ) -> Query<R, Option<V::Unwrapped>>
The greatest value of a number or string column; None over no
rows.
Sourcepub fn max_json<V>(
self,
column: Column<R, V>,
path: Vec<JsonPathSegment>,
) -> Query<R, Option<Value>>
pub fn max_json<V>( self, column: Column<R, V>, path: Vec<JsonPathSegment>, ) -> Query<R, Option<Value>>
Reduces the query to the greatest value at path in the JSON column.
Sourcepub fn distinct(
self,
columns: Vec<ColumnRef<R>>,
) -> Query<R, Vec<DistinctRow<R>>>
pub fn distinct( self, columns: Vec<ColumnRef<R>>, ) -> Query<R, Vec<DistinctRow<R>>>
The distinct combinations of columns among the rows where keeps.
count() after it counts the combinations.
Sourcepub fn group_by(self, columns: Vec<ColumnRef<R>>) -> GroupedQuery<R>
pub fn group_by(self, columns: Vec<ColumnRef<R>>) -> GroupedQuery<R>
Groups the rows by columns, for the aggregate that reduces each
group.
Source§impl<R, T: QueryValue> Query<R, T>
impl<R, T: QueryValue> Query<R, T>
Sourcepub fn read(&self, view: &ViewValue) -> Result<T, ZeroValueError>
pub fn read(&self, view: &ViewValue) -> Result<T, ZeroValueError>
Reads a view of this query as its result.