Struct aragog::query::Comparison[][src]

pub struct Comparison { /* fields omitted */ }

Struct representing one AQL comparison in a Query.

Implementations

impl Comparison[src]

pub fn field(field_name: &str) -> ComparisonBuilder[src]

Instantiates a new builder for a Comparison with the specified field_name. The field will be used as the left value of the comparison.

Example

Query::new("Users").filter(Filter::new(Comparison::field("name").equals_str("felix")));
// or
Query::new("Users").filter(Comparison::field("name").equals_str("felix").into());

pub fn all(array_field_name: &str) -> ComparisonBuilder[src]

Instantiates a new builder for a Comparison with the specified array_field_name. The field should be an array, as all items in the array will have to match the comparison to succeed.

Example

In this example the query will render all documents where every price is above 10.

Query::new("Products").filter(Filter::new(Comparison::all("prices").greater_or_equal(10)));
// or
Query::new("Users").filter(Comparison::all("prices").greater_or_equal(10).into());

pub fn none(array_field_name: &str) -> ComparisonBuilder[src]

Instantiates a new builder for a Comparison with the specified array_field_name. The field should be an array, none of the items in the array can match the comparison to succeed.

Example

In this example the query will render all documents where every price is not above 10.

Query::new("Products").filter(Filter::new(Comparison::none("prices").greater_or_equal(10)));
// or
Query::new("Users").filter(Comparison::none("prices").greater_or_equal(10).into());

pub fn any(array_field_name: &str) -> ComparisonBuilder[src]

Instantiates a new builder for a Comparison with the specified array_field_name. The field should be an array, at least one of the items in the array must match the comparison to succeed.

Example

In this example the query will render all documents where at least one price is above 10.

Query::new("Products").filter(Filter::new(Comparison::any("prices").greater_or_equal(10)));
// or
Query::new("Users").filter(Comparison::any("prices").greater_or_equal(10).into());

pub fn statement(statement: &str) -> ComparisonBuilder[src]

Instantiates a new builder for a Comparison with the specified statement. The field will be used as the left value of the comparison.

Example

Query::new("Products").filter(Filter::new(Comparison::statement("10 * 3").greater_or_equal(10)));
// or
Query::new("Products").filter(Comparison::statement("10 * 3").greater_or_equal(10).into());

pub fn and(self, comparison: Comparison) -> Filter[src]

Appends the filter current condition(s) with a new one with a AND logic. self will be treated as a Filter.

/// Both are equivalent
let a = Filter::new(Comparison::field("age").greater_than(10)).and(Comparison::field("age").lesser_or_equal(18));
let b = Comparison::field("age").greater_than(10).and(Comparison::field("age").lesser_or_equal(18));
assert_eq!(a.to_aql("i"), b.to_aql("i"));

pub fn or(self, comparison: Comparison) -> Filter[src]

Appends the filter current condition(s) with a new one with a OR logic. self will be treated as a Filter.

/// Both are equivalent
let a = Filter::new(Comparison::field("age").greater_than(10)).or(Comparison::field("age").lesser_or_equal(18));
let b = Comparison::field("age").greater_than(10).or(Comparison::field("age").lesser_or_equal(18));
assert_eq!(a.to_aql("i"), b.to_aql("i"));

pub fn to_aql(&self, collection_id: &str) -> String[src]

Renders self in a valid AQL format. collection_id is simply the collection identifier, it can be any string.

Note

You should not use this method except for debug purpose, use Query::to_aql instead

Example

use aragog::query::Comparison;
let comparison = Comparison::field("age").greater_than(18);

assert_eq!(comparison.to_aql("i").as_str(), "i.age > 18")

Trait Implementations

impl Clone for Comparison[src]

impl Debug for Comparison[src]

impl From<Comparison> for Filter[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.