query
Module[Query]: one filter, order, selection or pagination step of a find.
A query is a Method, an attribute and a list of values. Build one with
the constructors (Query::equal, Query::limit, Query::or, ...),
or parse the JSON clients send (Query::parse); Query::to_string
writes that JSON back. Query::group_by_type splits a find's queries
into filters, selections, orders, limit, offset and cursor, and
Query::fingerprint hashes their shape for slow-query grouping.
Rust
use utopia_database::Query;
let q = Query::or(vec![Query::equal("title", ["Iron Man"]), Query::greater_than("year", 2000)]);
let json = q.to_string().unwrap();
assert_eq!(
json,
r#"{"method":"or","values":[{"method":"equal","attribute":"title","values":["Iron Man"]},{"method":"greaterThan","attribute":"year","values":[2000]}]}"#
);
assert_eq!(Query::parse(&json).unwrap(), q);
assert_eq!(q.shape(), "or:(equal:title|greaterThan:year)");Contents
1 submodule, and what the module defines itself.
use utopia_database::Query;Rust
pub struct QueryOne query.
use utopia_database::query::Method;Rust
pub enum MethodA query method (Query::TYPE_*).
Also implements
Display.Rust
pub const DEFAULT_ALIAS: &str = "main"Undocumented.
Rust
pub const TYPES: [Method; 49] = [ Method::Equal, Method::NotEqual, Method::LessThan, Method::LessThanEqual, Method::GreaterThan, Method::GreaterThanEqual, Method::Contains, Method::ContainsAny, Method::NotContains, Method::Search, Method::NotSearch, Method::IsNull, Method::IsNotNull, Method::Between, Method::NotBetween, Method::StartsWith, Method::NotStartsWith, Method::EndsWith, Method::NotEndsWith, Method::Crosses, Method::NotCrosses, Method::DistanceEqual, Method::DistanceNotEqual, Method::DistanceGreaterThan, Method::DistanceLessThan, Method::Intersects, Method::NotIntersects, Method::Overlaps, Method::NotOverlaps,Undocumented.
Rust
pub const VECTOR_TYPES: [Method; 3] = [Method::VectorDot, Method::VectorCosine, Method::VectorEuclidean]Undocumented.
query::group
Own pageuse utopia_database::query::group::Grouped;Rust
pub struct GroupedA find's queries by kind.