Rust

[Order]: orderAsc, orderDesc and orderRandom queries.

Contents

use utopia_database::validator::query::order::Order;
Rust
pub struct Order

An order query on an attribute of the collection (any attribute when the adapter has no schema); orderRandom needs none. A dotted attribute orders by a relationship's attribute, which is refused.

Rust
use utopia_database::Document;
use utopia_database::query::{Method, Query};
use utopia_database::validator::query::order::Order;
use utopia_database::value::string;

let order = Order::new(&[Document::from_pairs([("key", string("name"))]).unwrap()], true);
assert!(order.check(&Query::new(Method::OrderAsc, "name", vec![])));
assert!(!order.check(&Query::new(Method::OrderAsc, "age", vec![])));
assert_eq!(order.description(), "Attribute not found in schema: age");
Also implements Default.