pub struct ComparisonBuilder { /* private fields */ }
Expand description

Builder for Comparison

Implementations§

source§

impl ComparisonBuilder

source

pub fn equals_str<T>(self, value: T) -> Comparisonwhere T: Display,

Finalizes the current query item builder with a string equality comparison.

Note

The field to be matched should be a string value as the AQL translation will put it between quotes. This means that if you use this with a numeric the final result will be between quotes.

Example
  • String example:

let query_item = Comparison::field("username").equals_str("felix");
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username == "felix" return a"#);
  • Numeric example:
// With the String equality
let query_item = Comparison::field("price").equals_str(10.5);
let query = Query::new("Product").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Product FILTER a.price == "10.5" return a"#);

// With simple equality
let query_item = Comparison::field("price").equals(10.5);
let query = Query::new("Product").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Product FILTER a.price == 10.5 return a");
source

pub fn different_than_str<T>(self, value: T) -> Comparisonwhere T: Display,

Finalizes the current query item builder with a string inequality comparison.

Note

The field to be matched should be a string value as the AQL translation will put it between quotes. This means that if you use this with a numeric the final result will be between quotes.

Example
  • String example:

let query_item = Comparison::field("username").different_than_str("felix");
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username != "felix" return a"#);
  • Numeric example:
// With the String equality
let query_item = Comparison::field("price").different_than_str(10.5);
let query = Query::new("Product").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Product FILTER a.price != "10.5" return a"#);

// With simple equality
let query_item = Comparison::field("price").different_than(10.5);
let query = Query::new("Product").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Product FILTER a.price != 10.5 return a");
source

pub fn matches(self, regular_expression: &str) -> Comparison

Finalizes the current query item builder with a regular expression matching. The field to be matched should be a string.

Example

let query_item = Comparison::field("username").matches(r#"^[0.9](0.6)$"#);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username =~ "^[0.9](0.6)$" return a"#);
source

pub fn does_not_match(self, regular_expression: &str) -> Comparison

Finalizes the current query item builder with an inverse regular expression matching. The field to be matched should be a string.

Example

let query_item = Comparison::field("username").does_not_match(r#"^[0.9](0.6)$"#);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username !~ "^[0.9](0.6)$" return a"#);
source

pub fn like(self, pattern: &str) -> Comparison

Finalizes the current query item builder with string comparison. The field to be matched should be a string.

Example

let query_item = Comparison::field("username").like("%felix%");
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username LIKE "%felix%" return a"#);
source

pub fn not_like(self, pattern: &str) -> Comparison

Finalizes the current query item builder with string comparison. The field to be matched should be a string.

Example

let query_item = Comparison::field("username").not_like("%felix%");
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username NOT LIKE "%felix%" return a"#);
source

pub fn equals<T>(self, value: T) -> Comparisonwhere T: Display,

Finalizes the current query item builder with an equality comparison.

Note

The field will not be put between quotes. This means you cannot use this for string comparison Use equals_str instead

Example
  • Numeric example:

let query_item = Comparison::field("age").equals(18);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age == 18 return a");
  • String example:
// With simple equality the comparison will fail
let query_item = Comparison::field("username").equals("felix");
let query = Query::new("User").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in User FILTER a.username == felix return a");

// With the String equality it would work
let query_item = Comparison::field("username").equals_str("felix");
let query = Query::new("User").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in User FILTER a.username == "felix" return a"#);
source

pub fn different_than<T>(self, value: T) -> Comparisonwhere T: Display,

Finalizes the current query item builder with an ineequality comparison.

Note

The field will not be put between quotes. This means you cannot use this for string comparison Use different_than_str instead

Example
  • Numeric example:

let query_item = Comparison::field("age").different_than(18);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age != 18 return a");
  • String example:
// With simple inequality the comparison will fail
let query_item = Comparison::field("username").different_than("felix");
let query = Query::new("User").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in User FILTER a.username != felix return a");

// With the String inequality it would work
let query_item = Comparison::field("username").different_than_str("felix");
let query = Query::new("User").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in User FILTER a.username != "felix" return a"#);
source

pub fn greater_than<T>(self, value: T) -> Comparisonwhere T: Num + Display,

Finalizes the current query item builder with numeric comparison. The field to be matched should be a numeric type.

Example

let query_item = Comparison::field("age").greater_than(18);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age > 18 return a");
source

pub fn greater_or_equal<T>(self, value: T) -> Comparisonwhere T: Num + Display,

Finalizes the current query item builder with numeric comparison. The field to be matched should be a numeric type.

Example

let query_item = Comparison::field("age").greater_or_equal(18);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age >= 18 return a");
source

pub fn lesser_than<T>(self, value: T) -> Comparisonwhere T: Num + Display,

Finalizes the current query item builder with numeric comparison. The field to be matched should be a numeric type.

Example

let query_item = Comparison::field("age").lesser_than(18);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age < 18 return a");
source

pub fn lesser_or_equal<T>(self, value: T) -> Comparisonwhere T: Num + Display,

Finalizes the current query item builder with numeric comparison. The field to be matched should be a numeric type.

Example

let query_item = Comparison::field("age").lesser_or_equal(18);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age <= 18 return a");
source

pub fn in_array<T>(self, array: &[T]) -> Comparisonwhere T: Display,

Finalizes the current query item builder with an inclusion in a numeric array comparison. The field to be matched should be a numeric type.

Example

let query_item = Comparison::field("age").in_array(&[1, 11, 16, 18]);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age IN [1, 11, 16, 18] return a");
source

pub fn not_in_array<T>(self, array: &[T]) -> Comparisonwhere T: Display,

Finalizes the current query item builder with an inclusion in a numeric array comparison. The field to be matched should be a numeric type.

Example

let query_item = Comparison::field("age").not_in_array(&[1, 11, 16, 18]);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.age NOT IN [1, 11, 16, 18] return a");
source

pub fn in_str_array<T>(self, array: &[T]) -> Comparisonwhere T: Display,

Finalizes the current query item builder with an inclusion in a string array comparison. The field to be matched should be a string type.

Example

let query_item = Comparison::field("username").in_str_array(&["felix", "123felix"]);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username IN ["felix", "123felix"] return a"#);
source

pub fn not_in_str_array<T>(self, array: &[T]) -> Comparisonwhere T: Display,

Finalizes the current query item builder with an inclusion in a string array comparison. The field to be matched should be a string type.

Example

let query_item = Comparison::field("username").not_in_str_array(&["felix", "123felix"]);
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), r#"FOR a in Users FILTER a.username NOT IN ["felix", "123felix"] return a"#);
source

pub fn is_null(self) -> Comparison

👎Deprecated since 0.17.0: use eq_null instead

Finalizes the current query item builder with a null comparison.

Example

let query_item = Comparison::field("username").is_null();
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.username == null return a");
source

pub fn eq_null(self) -> Comparison

Finalizes the current query item builder with a null comparison.

Example

let query_item = Comparison::field("username").eq_null();
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.username == null return a");
source

pub fn not_null(self) -> Comparison

Finalizes the current query item builder with a not null comparison.

Example

let query_item = Comparison::field("username").not_null();
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.username != null return a");
source

pub fn is_true(self) -> Comparison

👎Deprecated since 0.17.0: use eq_true instead

Finalizes the current query item builder with a boolean comparison. The field to be matched should be a boolean type.

Example

let query_item = Comparison::field("is_authorized").is_true();
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.is_authorized == true return a");
source

pub fn eq_true(self) -> Comparison

Finalizes the current query item builder with a boolean comparison. The field to be matched should be a boolean type.

Example

let query_item = Comparison::field("is_authorized").eq_true();
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.is_authorized == true return a");
source

pub fn is_false(self) -> Comparison

👎Deprecated since 0.17.0: use eq_false instead

Finalizes the current query item builder with a boolean comparison. The field to be matched should be a boolean type.

Example

let query_item = Comparison::field("is_authorized").is_false();
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.is_authorized == false return a");
source

pub fn eq_false(self) -> Comparison

Finalizes the current query item builder with a boolean comparison. The field to be matched should be a boolean type.

Example

let query_item = Comparison::field("is_authorized").eq_false();
let query = Query::new("Users").filter(Filter::new(query_item));
assert_eq!(query.aql_str(), "FOR a in Users FILTER a.is_authorized == false return a");

Trait Implementations§

source§

impl Clone for ComparisonBuilder

source§

fn clone(&self) -> ComparisonBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ComparisonBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more