pub struct Query { /* private fields */ }Expand description
One query: a Method, the attribute it applies to, its values, and the
alias a join or an aggregate is exposed under.
Values are PHP values (Value); nested queries (the children of and,
or, having, the conditions of a join) are values too.
PHP: Utopia\Query\Query.
use utopia_query::{Method, Query};
let query = Query::equal("status", ["active", "pending"]);
assert_eq!(query.method(), Method::Equal);
assert_eq!(query.to_string()?, r#"{"method":"equal","attribute":"status","values":["active","pending"]}"#);use Utopia\Query\Query;
$query = Query::equal('status', ['active', 'pending']);
echo $query->getMethod()->value, "\n"; // equal
echo $query->toString(), "\n"; // {"method":"equal","attribute":"status","values":["active","pending"]}Implementations§
Source§impl Query
impl Query
Sourcepub fn new(
method: Method,
attribute: impl Into<String>,
values: Array,
alias: impl Into<String>,
) -> Self
pub fn new( method: Method, attribute: impl Into<String>, values: Array, alias: impl Into<String>, ) -> Self
A query of method on attribute with values and alias.
PHP: new Query($method, $attribute, $values, $alias).
Sourcepub fn attribute(&self) -> &str
pub fn attribute(&self) -> &str
The attribute (for a join: the joined collection; for raw: the SQL).
PHP: getAttribute().
Sourcepub fn value(&self) -> Option<&Value>
pub fn value(&self) -> Option<&Value>
The first value (values[0]), if any.
PHP: getValue($default) is value().unwrap_or(default).
Sourcepub fn alias(&self) -> &str
pub fn alias(&self) -> &str
The name a join or an aggregate is exposed under, or "".
PHP: getAlias().
Sourcepub fn is_alias_defaulted(&self) -> bool
pub fn is_alias_defaulted(&self) -> bool
Whether a join is read under the name of the collection it joins, as a join given no alias is. Decided when the query is built, so it holds after the collection is renamed.
PHP: isAliasDefaulted().
Sourcepub fn on_array(&self) -> bool
pub fn on_array(&self) -> bool
Whether the attribute holds arrays (set by the database layer).
PHP: onArray().
Sourcepub fn attribute_type(&self) -> &str
pub fn attribute_type(&self) -> &str
The attribute’s type (set by the database layer), or "".
PHP: getAttributeType().
Sourcepub fn set_method(&mut self, method: Method) -> &mut Self
pub fn set_method(&mut self, method: Method) -> &mut Self
Sets the method.
PHP: setMethod().
Sourcepub fn set_attribute(&mut self, attribute: impl Into<String>) -> &mut Self
pub fn set_attribute(&mut self, attribute: impl Into<String>) -> &mut Self
Sets the attribute.
PHP: setAttribute().
Sourcepub fn set_values(&mut self, values: Array) -> &mut Self
pub fn set_values(&mut self, values: Array) -> &mut Self
Replaces the values.
PHP: setValues().
Sourcepub fn set_value(&mut self, value: Value) -> &mut Self
pub fn set_value(&mut self, value: Value) -> &mut Self
Replaces the values with one value.
PHP: setValue().
Sourcepub fn set_on_array(&mut self, on_array: bool)
pub fn set_on_array(&mut self, on_array: bool)
Sets whether the attribute holds arrays.
PHP: setOnArray().
Sourcepub fn set_attribute_type(&mut self, attribute_type: impl Into<String>)
pub fn set_attribute_type(&mut self, attribute_type: impl Into<String>)
Sets the attribute’s type.
PHP: setAttributeType().
Sourcepub fn is_nested_join(&self) -> bool
pub fn is_nested_join(&self) -> bool
Whether this is a join whose values hold ON conditions.
PHP: isNestedJoin().
Sourcepub fn join_on_queries(&self) -> Vec<&Query>
pub fn join_on_queries(&self) -> Vec<&Query>
The ON conditions of a join (empty for other queries).
PHP: getJoinOnQueries().
Sourcepub fn is_method(value: &str) -> bool
pub fn is_method(value: &str) -> bool
Whether value is the name of a method.
PHP: Query::isMethod().
Sourcepub fn is_spatial_query(&self) -> bool
pub fn is_spatial_query(&self) -> bool
Whether the method is spatial.
PHP: isSpatialQuery().
Sourcepub fn parse(query: &str, allow_raw: bool) -> Result<Query>
pub fn parse(query: &str, allow_raw: bool) -> Result<Query>
Parses a query from JSON. Raw queries are refused unless allow_raw:
they bypass bindings, so JSON from an untrusted source must not carry them.
PHP: Query::parse($query, $allowRaw).
use utopia_query::{Method, Query};
let query = Query::parse(r#"{"method":"greaterThan","attribute":"age","values":[18]}"#, false)?;
assert_eq!(query.method(), Method::GreaterThan);
assert!(Query::parse(r#"{"method":"raw","attribute":"1 = 1"}"#, false).is_err());use Utopia\Query\Query;
$query = Query::parse('{"method":"greaterThan","attribute":"age","values":[18]}');
echo $query->getMethod()->value, "\n"; // greaterThanSourcepub fn parse_bytes(query: &[u8], allow_raw: bool) -> Result<Query>
pub fn parse_bytes(query: &[u8], allow_raw: bool) -> Result<Query>
Query::parse on bytes (PHP strings need not be UTF-8).
Sourcepub fn parse_query(query: &Array, allow_raw: bool) -> Result<Query>
pub fn parse_query(query: &Array, allow_raw: bool) -> Result<Query>
Parses a query from its decoded array form (method, attribute,
values, alias). Raw queries are refused unless allow_raw.
PHP: Query::parseQuery($query, $allowRaw).
Sourcepub fn parse_queries<S: AsRef<str>>(
queries: &[S],
allow_raw: bool,
) -> Result<Vec<Query>>
pub fn parse_queries<S: AsRef<str>>( queries: &[S], allow_raw: bool, ) -> Result<Vec<Query>>
Parses each query of queries (see Query::parse).
PHP: Query::parseQueries().
Sourcepub fn fingerprint(queries: &[QueryOrJson<'_>]) -> Result<String>
pub fn fingerprint(queries: &[QueryOrJson<'_>]) -> Result<String>
A fingerprint of the queries’ shape: methods and attributes, without values, independent of order, as an MD5 hex digest. Two lists that differ only in values have the same fingerprint (useful to group slow queries).
PHP: Query::fingerprint().
use utopia_query::{Query, QueryOrJson};
let a = Query::equal("status", ["active"]);
let b = Query::equal("status", ["archived"]);
assert_eq!(Query::fingerprint(&[QueryOrJson::Query(&a)])?, Query::fingerprint(&[QueryOrJson::Query(&b)])?);use Utopia\Query\Query;
var_dump(Query::fingerprint([Query::equal('status', ['active'])]) === Query::fingerprint([Query::equal('status', ['archived'])])); // bool(true)Sourcepub fn shape(&self) -> String
pub fn shape(&self) -> String
The shape of this query, without values: method:attribute, and for
and, or, elemMatch and joins with conditions
method:attribute(child|child) with the children’s shapes sorted.
PHP: shape().
Sourcepub fn to_array(&self) -> Array
pub fn to_array(&self) -> Array
The query as an array: method, attribute (unless empty), alias
(unless empty) and values, nested queries as arrays.
PHP: toArray().
Sourcepub fn compile(&self, compiler: &mut dyn Compiler) -> Result<String>
pub fn compile(&self, compiler: &mut dyn Compiler) -> Result<String>
Compiles this query with compiler, by kind.
PHP: compile(Compiler $compiler).
Sourcepub fn equal(attribute: impl Into<String>, values: impl IntoValues) -> Self
pub fn equal(attribute: impl Into<String>, values: impl IntoValues) -> Self
equal: the attribute is one of values.
PHP: Query::equal().
Sourcepub fn not_equal(attribute: impl Into<String>, value: impl IntoValue) -> Self
pub fn not_equal(attribute: impl Into<String>, value: impl IntoValue) -> Self
notEqual: the attribute is not value; a list means none of its
items (an associative array is one value).
PHP: Query::notEqual().
Sourcepub fn less_than(attribute: impl Into<String>, value: impl IntoValue) -> Self
pub fn less_than(attribute: impl Into<String>, value: impl IntoValue) -> Self
lessThan.
PHP: Query::lessThan().
Sourcepub fn less_than_equal(
attribute: impl Into<String>,
value: impl IntoValue,
) -> Self
pub fn less_than_equal( attribute: impl Into<String>, value: impl IntoValue, ) -> Self
lessThanEqual.
PHP: Query::lessThanEqual().
Sourcepub fn greater_than(attribute: impl Into<String>, value: impl IntoValue) -> Self
pub fn greater_than(attribute: impl Into<String>, value: impl IntoValue) -> Self
greaterThan.
PHP: Query::greaterThan().
Sourcepub fn greater_than_equal(
attribute: impl Into<String>,
value: impl IntoValue,
) -> Self
pub fn greater_than_equal( attribute: impl Into<String>, value: impl IntoValue, ) -> Self
greaterThanEqual.
PHP: Query::greaterThanEqual().
Sourcepub fn contains(attribute: impl Into<String>, values: impl IntoValues) -> Self
pub fn contains(attribute: impl Into<String>, values: impl IntoValues) -> Self
contains: a substring of a string attribute, or an element of an
array attribute.
PHP: Query::contains() (deprecated: prefer Query::contains_string
or Query::contains_any).
Sourcepub fn contains_string(
attribute: impl Into<String>,
values: impl IntoValues,
) -> Self
pub fn contains_string( attribute: impl Into<String>, values: impl IntoValues, ) -> Self
contains on a string attribute: LIKE '%value%' for each value.
PHP: Query::containsString().
Sourcepub fn contains_any(
attribute: impl Into<String>,
values: impl IntoValues,
) -> Self
pub fn contains_any( attribute: impl Into<String>, values: impl IntoValues, ) -> Self
containsAny: an array attribute holds any of the values.
PHP: Query::containsAny().
Sourcepub fn not_contains(
attribute: impl Into<String>,
values: impl IntoValues,
) -> Self
pub fn not_contains( attribute: impl Into<String>, values: impl IntoValues, ) -> Self
notContains.
PHP: Query::notContains().
Sourcepub fn between(
attribute: impl Into<String>,
start: impl IntoValue,
end: impl IntoValue,
) -> Self
pub fn between( attribute: impl Into<String>, start: impl IntoValue, end: impl IntoValue, ) -> Self
between (inclusive).
PHP: Query::between().
Sourcepub fn not_between(
attribute: impl Into<String>,
start: impl IntoValue,
end: impl IntoValue,
) -> Self
pub fn not_between( attribute: impl Into<String>, start: impl IntoValue, end: impl IntoValue, ) -> Self
notBetween.
PHP: Query::notBetween().
Sourcepub fn search(attribute: impl Into<String>, value: impl IntoValue) -> Self
pub fn search(attribute: impl Into<String>, value: impl IntoValue) -> Self
search: full-text search.
PHP: Query::search().
Sourcepub fn not_search(attribute: impl Into<String>, value: impl IntoValue) -> Self
pub fn not_search(attribute: impl Into<String>, value: impl IntoValue) -> Self
notSearch.
PHP: Query::notSearch().
Sourcepub fn select<S: Into<String>>(attributes: impl IntoIterator<Item = S>) -> Self
pub fn select<S: Into<String>>(attributes: impl IntoIterator<Item = S>) -> Self
select: the attributes to return.
PHP: Query::select().
Sourcepub fn select_values(values: Array) -> Self
pub fn select_values(values: Array) -> Self
select with any values (PHP accepts an array of anything).
Sourcepub fn order_desc(
attribute: impl Into<String>,
nulls: Option<NullsPosition>,
) -> Self
pub fn order_desc( attribute: impl Into<String>, nulls: Option<NullsPosition>, ) -> Self
orderDesc, with where NULLs sort.
PHP: Query::orderDesc().
Sourcepub fn order_asc(
attribute: impl Into<String>,
nulls: Option<NullsPosition>,
) -> Self
pub fn order_asc( attribute: impl Into<String>, nulls: Option<NullsPosition>, ) -> Self
orderAsc, with where NULLs sort.
PHP: Query::orderAsc().
Sourcepub fn order_random() -> Self
pub fn order_random() -> Self
orderRandom.
PHP: Query::orderRandom().
Sourcepub fn cursor_after(row: Value) -> Self
pub fn cursor_after(row: Value) -> Self
cursorAfter: page after a row (an array of its columns, a
stdClass, or a Object::Row).
PHP: Query::cursorAfter().
Sourcepub fn cursor_before(row: Value) -> Self
pub fn cursor_before(row: Value) -> Self
cursorBefore: page before a row.
PHP: Query::cursorBefore().
Sourcepub fn is_not_null(attribute: impl Into<String>) -> Self
pub fn is_not_null(attribute: impl Into<String>) -> Self
isNotNull.
PHP: Query::isNotNull().
Sourcepub fn starts_with(attribute: impl Into<String>, value: impl IntoValue) -> Self
pub fn starts_with(attribute: impl Into<String>, value: impl IntoValue) -> Self
startsWith.
PHP: Query::startsWith().
Sourcepub fn not_starts_with(
attribute: impl Into<String>,
value: impl IntoValue,
) -> Self
pub fn not_starts_with( attribute: impl Into<String>, value: impl IntoValue, ) -> Self
notStartsWith.
PHP: Query::notStartsWith().
Sourcepub fn ends_with(attribute: impl Into<String>, value: impl IntoValue) -> Self
pub fn ends_with(attribute: impl Into<String>, value: impl IntoValue) -> Self
endsWith.
PHP: Query::endsWith().
Sourcepub fn not_ends_with(
attribute: impl Into<String>,
value: impl IntoValue,
) -> Self
pub fn not_ends_with( attribute: impl Into<String>, value: impl IntoValue, ) -> Self
notEndsWith.
PHP: Query::notEndsWith().
Sourcepub fn created_before(value: impl IntoValue) -> Self
pub fn created_before(value: impl IntoValue) -> Self
Documents created before a date: lessThan('$createdAt', value).
PHP: Query::createdBefore().
Sourcepub fn created_after(value: impl IntoValue) -> Self
pub fn created_after(value: impl IntoValue) -> Self
Documents created after a date.
PHP: Query::createdAfter().
Sourcepub fn updated_before(value: impl IntoValue) -> Self
pub fn updated_before(value: impl IntoValue) -> Self
Documents updated before a date.
PHP: Query::updatedBefore().
Sourcepub fn updated_after(value: impl IntoValue) -> Self
pub fn updated_after(value: impl IntoValue) -> Self
Documents updated after a date.
PHP: Query::updatedAfter().
Sourcepub fn created_between(start: impl IntoValue, end: impl IntoValue) -> Self
pub fn created_between(start: impl IntoValue, end: impl IntoValue) -> Self
Documents created between two dates.
PHP: Query::createdBetween().
Sourcepub fn updated_between(start: impl IntoValue, end: impl IntoValue) -> Self
pub fn updated_between(start: impl IntoValue, end: impl IntoValue) -> Self
Documents updated between two dates.
PHP: Query::updatedBetween().
Sourcepub fn or(queries: impl IntoIterator<Item = Query>) -> Self
pub fn or(queries: impl IntoIterator<Item = Query>) -> Self
or of queries.
PHP: Query::or().
Sourcepub fn and(queries: impl IntoIterator<Item = Query>) -> Self
pub fn and(queries: impl IntoIterator<Item = Query>) -> Self
and of queries.
PHP: Query::and().
Sourcepub fn logical(method: Method, values: Array) -> Self
pub fn logical(method: Method, values: Array) -> Self
A logical query of any values (PHP accepts an array of anything).
Sourcepub fn contains_all(
attribute: impl Into<String>,
values: impl IntoValues,
) -> Self
pub fn contains_all( attribute: impl Into<String>, values: impl IntoValues, ) -> Self
containsAll: an array attribute holds every value.
PHP: Query::containsAll().
Sourcepub fn by_type<'a>(queries: &'a [Query], methods: &[Method]) -> Vec<&'a Query>
pub fn by_type<'a>(queries: &'a [Query], methods: &[Method]) -> Vec<&'a Query>
The queries of the given methods.
PHP: Query::getByType() (the clone flag is moot: these are references).
Sourcepub fn cursor_queries(queries: &[Query]) -> Vec<&Query>
pub fn cursor_queries(queries: &[Query]) -> Vec<&Query>
The cursor queries.
PHP: Query::getCursorQueries().
Sourcepub fn group_by_type(queries: &[Query]) -> ParsedQuery
pub fn group_by_type(queries: &[Query]) -> ParsedQuery
Groups queries by what they do (see ParsedQuery).
PHP: Query::groupByType().
Sourcepub fn distance_equal(
attribute: impl Into<String>,
values: Array,
distance: impl IntoValue,
meters: bool,
) -> Self
pub fn distance_equal( attribute: impl Into<String>, values: Array, distance: impl IntoValue, meters: bool, ) -> Self
distanceEqual: the distance from values (a point or a geometry)
equals distance (in meters when meters).
PHP: Query::distanceEqual().
Sourcepub fn distance_not_equal(
attribute: impl Into<String>,
values: Array,
distance: impl IntoValue,
meters: bool,
) -> Self
pub fn distance_not_equal( attribute: impl Into<String>, values: Array, distance: impl IntoValue, meters: bool, ) -> Self
distanceNotEqual.
PHP: Query::distanceNotEqual().
Sourcepub fn distance_greater_than(
attribute: impl Into<String>,
values: Array,
distance: impl IntoValue,
meters: bool,
) -> Self
pub fn distance_greater_than( attribute: impl Into<String>, values: Array, distance: impl IntoValue, meters: bool, ) -> Self
distanceGreaterThan.
PHP: Query::distanceGreaterThan().
Sourcepub fn distance_less_than(
attribute: impl Into<String>,
values: Array,
distance: impl IntoValue,
meters: bool,
) -> Self
pub fn distance_less_than( attribute: impl Into<String>, values: Array, distance: impl IntoValue, meters: bool, ) -> Self
distanceLessThan.
PHP: Query::distanceLessThan().
Sourcepub fn intersects(attribute: impl Into<String>, values: Array) -> Self
pub fn intersects(attribute: impl Into<String>, values: Array) -> Self
intersects (spatial).
PHP: Query::intersects().
Sourcepub fn not_intersects(attribute: impl Into<String>, values: Array) -> Self
pub fn not_intersects(attribute: impl Into<String>, values: Array) -> Self
notIntersects (spatial).
PHP: Query::notIntersects().
Sourcepub fn crosses(attribute: impl Into<String>, values: Array) -> Self
pub fn crosses(attribute: impl Into<String>, values: Array) -> Self
crosses (spatial).
PHP: Query::crosses().
Sourcepub fn not_crosses(attribute: impl Into<String>, values: Array) -> Self
pub fn not_crosses(attribute: impl Into<String>, values: Array) -> Self
notCrosses (spatial).
PHP: Query::notCrosses().
Sourcepub fn overlaps(attribute: impl Into<String>, values: Array) -> Self
pub fn overlaps(attribute: impl Into<String>, values: Array) -> Self
overlaps (spatial).
PHP: Query::overlaps().
Sourcepub fn not_overlaps(attribute: impl Into<String>, values: Array) -> Self
pub fn not_overlaps(attribute: impl Into<String>, values: Array) -> Self
notOverlaps (spatial).
PHP: Query::notOverlaps().
Sourcepub fn touches(attribute: impl Into<String>, values: Array) -> Self
pub fn touches(attribute: impl Into<String>, values: Array) -> Self
touches (spatial).
PHP: Query::touches().
Sourcepub fn not_touches(attribute: impl Into<String>, values: Array) -> Self
pub fn not_touches(attribute: impl Into<String>, values: Array) -> Self
notTouches (spatial).
PHP: Query::notTouches().
Sourcepub fn vector_dot(attribute: impl Into<String>, vector: Array) -> Self
pub fn vector_dot(attribute: impl Into<String>, vector: Array) -> Self
vectorDot: similarity to vector by dot product.
PHP: Query::vectorDot().
Sourcepub fn vector_cosine(attribute: impl Into<String>, vector: Array) -> Self
pub fn vector_cosine(attribute: impl Into<String>, vector: Array) -> Self
vectorCosine.
PHP: Query::vectorCosine().
Sourcepub fn vector_euclidean(attribute: impl Into<String>, vector: Array) -> Self
pub fn vector_euclidean(attribute: impl Into<String>, vector: Array) -> Self
vectorEuclidean.
PHP: Query::vectorEuclidean().
Sourcepub fn regex(attribute: impl Into<String>, pattern: impl IntoValue) -> Self
pub fn regex(attribute: impl Into<String>, pattern: impl IntoValue) -> Self
regex.
PHP: Query::regex().
Sourcepub fn exists(attributes: Array) -> Self
pub fn exists(attributes: Array) -> Self
exists: the attributes are present.
PHP: Query::exists().
Sourcepub fn not_exists(attribute: impl IntoValue) -> Self
pub fn not_exists(attribute: impl IntoValue) -> Self
notExists: the attribute (or each of a list) is absent.
PHP: Query::notExists().
Sourcepub fn elem_match(
attribute: impl Into<String>,
queries: impl IntoIterator<Item = Query>,
) -> Self
pub fn elem_match( attribute: impl Into<String>, queries: impl IntoIterator<Item = Query>, ) -> Self
elemMatch: an element of the array attribute matches every query.
PHP: Query::elemMatch().
Sourcepub fn relationship(
attribute: impl Into<String>,
queries: impl IntoIterator<Item = Query>,
) -> Self
pub fn relationship( attribute: impl Into<String>, queries: impl IntoIterator<Item = Query>, ) -> Self
relationship: queries, written against the related collection,
that shape the documents populated for the relationship attribute.
It is nested, and validate() skips it: its queries name another
collection’s attributes.
use utopia_query::{Method, Query};
let query = Query::relationship("books", [Query::limit(2)]);
assert_eq!(query.method(), Method::Relationship);
assert!(Method::Relationship.is_nested());
assert_eq!(query.shape(), "relationship:books(limit:)");
assert!(Query::validate(&[query], &["title"]).unwrap().is_empty());PHP: Query::relationship().
Sourcepub fn count(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn count(attribute: impl Into<String>, alias: impl Into<String>) -> Self
count (* counts rows).
PHP: Query::count().
Sourcepub fn count_distinct(
attribute: impl Into<String>,
alias: impl Into<String>,
) -> Self
pub fn count_distinct( attribute: impl Into<String>, alias: impl Into<String>, ) -> Self
countDistinct.
PHP: Query::countDistinct().
Sourcepub fn sum(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn sum(attribute: impl Into<String>, alias: impl Into<String>) -> Self
sum.
PHP: Query::sum().
Sourcepub fn avg(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn avg(attribute: impl Into<String>, alias: impl Into<String>) -> Self
avg.
PHP: Query::avg().
Sourcepub fn min(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn min(attribute: impl Into<String>, alias: impl Into<String>) -> Self
min.
PHP: Query::min().
Sourcepub fn max(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn max(attribute: impl Into<String>, alias: impl Into<String>) -> Self
max.
PHP: Query::max().
Sourcepub fn stddev(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn stddev(attribute: impl Into<String>, alias: impl Into<String>) -> Self
stddev.
PHP: Query::stddev().
Sourcepub fn stddev_pop(
attribute: impl Into<String>,
alias: impl Into<String>,
) -> Self
pub fn stddev_pop( attribute: impl Into<String>, alias: impl Into<String>, ) -> Self
stddevPop.
PHP: Query::stddevPop().
Sourcepub fn stddev_samp(
attribute: impl Into<String>,
alias: impl Into<String>,
) -> Self
pub fn stddev_samp( attribute: impl Into<String>, alias: impl Into<String>, ) -> Self
stddevSamp.
PHP: Query::stddevSamp().
Sourcepub fn variance(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn variance(attribute: impl Into<String>, alias: impl Into<String>) -> Self
variance.
PHP: Query::variance().
Sourcepub fn var_pop(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn var_pop(attribute: impl Into<String>, alias: impl Into<String>) -> Self
varPop.
PHP: Query::varPop().
Sourcepub fn var_samp(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn var_samp(attribute: impl Into<String>, alias: impl Into<String>) -> Self
varSamp.
PHP: Query::varSamp().
Sourcepub fn bit_and(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn bit_and(attribute: impl Into<String>, alias: impl Into<String>) -> Self
bitAnd.
PHP: Query::bitAnd().
Sourcepub fn bit_or(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn bit_or(attribute: impl Into<String>, alias: impl Into<String>) -> Self
bitOr.
PHP: Query::bitOr().
Sourcepub fn bit_xor(attribute: impl Into<String>, alias: impl Into<String>) -> Self
pub fn bit_xor(attribute: impl Into<String>, alias: impl Into<String>) -> Self
bitXor.
PHP: Query::bitXor().
Sourcepub fn group_by<S: Into<String>>(
attributes: impl IntoIterator<Item = S>,
) -> Self
pub fn group_by<S: Into<String>>( attributes: impl IntoIterator<Item = S>, ) -> Self
groupBy.
PHP: Query::groupBy().
Sourcepub fn group_by_time_bucket(
attribute: impl Into<String>,
interval: &str,
) -> Result<Self>
pub fn group_by_time_bucket( attribute: impl Into<String>, interval: &str, ) -> Result<Self>
groupByTimeBucket: groups by attribute cut into windows of
interval (one of GROUP_BY_TIME_BUCKET_INTERVALS).
PHP: Query::groupByTimeBucket().
Sourcepub fn having(queries: impl IntoIterator<Item = Query>) -> Self
pub fn having(queries: impl IntoIterator<Item = Query>) -> Self
having: conditions on aggregates.
PHP: Query::having().
Sourcepub fn on(
left: impl Into<String>,
right: impl Into<String>,
operator: impl Into<String>,
) -> Self
pub fn on( left: impl Into<String>, right: impl Into<String>, operator: impl Into<String>, ) -> Self
on: a column-to-column join condition (operator defaults to = in PHP).
PHP: Query::on().
Sourcepub fn join(
collection: impl Into<String>,
alias: impl Into<String>,
on: Vec<Query>,
) -> Result<Self>
pub fn join( collection: impl Into<String>, alias: impl Into<String>, on: Vec<Query>, ) -> Result<Self>
An inner join of collection as alias on conditions (on queries and filters).
PHP: Query::join().
Sourcepub fn left_join(
collection: impl Into<String>,
alias: impl Into<String>,
on: Vec<Query>,
) -> Result<Self>
pub fn left_join( collection: impl Into<String>, alias: impl Into<String>, on: Vec<Query>, ) -> Result<Self>
A left join.
PHP: Query::leftJoin().
Sourcepub fn right_join(
collection: impl Into<String>,
alias: impl Into<String>,
on: Vec<Query>,
) -> Result<Self>
pub fn right_join( collection: impl Into<String>, alias: impl Into<String>, on: Vec<Query>, ) -> Result<Self>
A right join.
PHP: Query::rightJoin().
Sourcepub fn full_outer_join(
collection: impl Into<String>,
alias: impl Into<String>,
on: Vec<Query>,
) -> Result<Self>
pub fn full_outer_join( collection: impl Into<String>, alias: impl Into<String>, on: Vec<Query>, ) -> Result<Self>
A full outer join.
PHP: Query::fullOuterJoin().
Sourcepub fn cross_join(
collection: impl Into<String>,
alias: impl Into<String>,
) -> Result<Self>
pub fn cross_join( collection: impl Into<String>, alias: impl Into<String>, ) -> Result<Self>
A cross join (no conditions).
PHP: Query::crossJoin().
Sourcepub fn natural_join(
collection: impl Into<String>,
alias: impl Into<String>,
) -> Result<Self>
pub fn natural_join( collection: impl Into<String>, alias: impl Into<String>, ) -> Result<Self>
A natural join (no conditions).
PHP: Query::naturalJoin().
Sourcepub fn join_values(
method: Method,
collection: impl Into<String>,
alias: impl Into<String>,
on: Array,
) -> Result<Self>
pub fn join_values( method: Method, collection: impl Into<String>, alias: impl Into<String>, on: Array, ) -> Result<Self>
A join of any conditions (values that must all be queries, as PHP checks).
Sourcepub fn union(queries: impl IntoIterator<Item = Query>) -> Self
pub fn union(queries: impl IntoIterator<Item = Query>) -> Self
union of queries.
PHP: Query::union().
Sourcepub fn union_all(queries: impl IntoIterator<Item = Query>) -> Self
pub fn union_all(queries: impl IntoIterator<Item = Query>) -> Self
unionAll of queries.
PHP: Query::unionAll().
Sourcepub fn json_contains(
attribute: impl Into<String>,
value: impl IntoValue,
) -> Self
pub fn json_contains( attribute: impl Into<String>, value: impl IntoValue, ) -> Self
jsonContains: a JSON attribute contains value.
PHP: Query::jsonContains().
Sourcepub fn json_not_contains(
attribute: impl Into<String>,
value: impl IntoValue,
) -> Self
pub fn json_not_contains( attribute: impl Into<String>, value: impl IntoValue, ) -> Self
jsonNotContains.
PHP: Query::jsonNotContains().
Sourcepub fn json_overlaps(attribute: impl Into<String>, values: Array) -> Self
pub fn json_overlaps(attribute: impl Into<String>, values: Array) -> Self
jsonOverlaps: a JSON array attribute shares an element with values.
PHP: Query::jsonOverlaps().
Sourcepub fn json_path(
attribute: impl Into<String>,
path: impl Into<String>,
operator: impl Into<String>,
value: impl IntoValue,
) -> Self
pub fn json_path( attribute: impl Into<String>, path: impl Into<String>, operator: impl Into<String>, value: impl IntoValue, ) -> Self
jsonPath: the value at path compares to value with operator.
PHP: Query::jsonPath().
Sourcepub fn covers(attribute: impl Into<String>, values: Array) -> Self
pub fn covers(attribute: impl Into<String>, values: Array) -> Self
covers (spatial).
PHP: Query::covers().
Sourcepub fn not_covers(attribute: impl Into<String>, values: Array) -> Self
pub fn not_covers(attribute: impl Into<String>, values: Array) -> Self
notCovers (spatial).
PHP: Query::notCovers().
Sourcepub fn spatial_equals(attribute: impl Into<String>, values: Array) -> Self
pub fn spatial_equals(attribute: impl Into<String>, values: Array) -> Self
spatialEquals (spatial).
PHP: Query::spatialEquals().
Sourcepub fn not_spatial_equals(attribute: impl Into<String>, values: Array) -> Self
pub fn not_spatial_equals(attribute: impl Into<String>, values: Array) -> Self
notSpatialEquals (spatial).
PHP: Query::notSpatialEquals().
Sourcepub fn raw(sql: impl Into<String>, bindings: Array) -> Self
pub fn raw(sql: impl Into<String>, bindings: Array) -> Self
raw: SQL used as given, with its bindings.
PHP: Query::raw().
Sourcepub fn page(page: i64, per_page: i64) -> Result<[Query; 2]>
pub fn page(page: i64, per_page: i64) -> Result<[Query; 2]>
The limit and offset of page page (from 1) of per_page rows.
PHP: Query::page().
Sourcepub fn merge(a: &[Query], b: &[Query]) -> Vec<Query>
pub fn merge(a: &[Query], b: &[Query]) -> Vec<Query>
a followed by b, where a limit, offset or cursor in b
replaces any of the same method in a.
PHP: Query::merge().
Sourcepub fn diff(a: &[Query], b: &[Query]) -> Vec<Query>
pub fn diff(a: &[Query], b: &[Query]) -> Vec<Query>
The queries of a not in b (compared by their array form).
PHP: Query::diff().
Sourcepub fn validate<S: AsRef<str>>(
queries: &[Query],
allowed: &[S],
) -> Result<Vec<String>>
pub fn validate<S: AsRef<str>>( queries: &[Query], allowed: &[S], ) -> Result<Vec<String>>
Error messages for attributes outside allowed (nested queries
included; pagination, selections and existence checks skipped). Fails
as PHP does when a groupBy column is an object it cannot print.
PHP: Query::validate().