[][src]Struct toql::query::Query

pub struct Query {
    pub distinct: bool,
    pub roles: BTreeSet<String>,
    // some fields omitted
}

A Query contains fields and wildcards. It can be turned into SQL using the SQL Builder.

To build a big query simple add fields and wildcards with and resp. or function.

Watch out: Logical AND has precendence over OR. So a AND b OR c is the same as a AND (b OR c). To insert parens in a query, build a separate query and add it with or. This will add parens automatically.

This example is not tested
let q1 = Query::new().and(Field("b").eq(3)).and(Field("c").eq(2));
let q2 = Query::new().and(Field("a").eq(1)).or(q1);

assert_eq!("a eq 1; (b eq 3, c eq 2)", q2.to_string())

Fields

distinct: boolroles: BTreeSet<String>

Methods

impl Query[src]

pub fn new() -> Query[src]

Create a new empty query.

pub fn wildcard() -> Query[src]

Create a new query that select all top fields.

pub fn double_wildcard() -> Query[src]

Create a new query that select all top fields and all dependend fields. This is the best :)

pub fn and<T>(self, query: T) -> Query where
    T: Into<Query>, 
[src]

Concatenate field or query with AND to query

pub fn or<T>(self, query: T) -> Query where
    T: Into<Query>, 
[src]

Concatenate field or query with OR to query. Puts parens around queries with more than one field.

pub fn prepend<T>(self, query: T) -> Query where
    T: Into<Query>, 
[src]

Trait Implementations

impl Debug for Query[src]

impl Clone for Query[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl From<Field> for Query[src]

impl<'_> From<&'_ str> for Query[src]

impl From<Wildcard> for Query[src]

impl Display for Query[src]

Auto Trait Implementations

impl Send for Query

impl Sync for Query

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> 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.

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

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

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