[][src]Struct ejdb::query::QueryHints

pub struct QueryHints { /* fields omitted */ }

A container of EJDB query options.

This structure is a wrapper around a BSON document with various options affecting query execution in EJDB. It implements Deref<Target=bson::Document> and DerefMut, therefore it is possible to work with it as a BSON document directly. It also has into_bson()/as_bson() methods and Into<bson::Document>/From<bson::Document> implementations. If an invalid document is constructed and passed as a hints map when executing a query, an error will be returned.

Query hints are a part of any query operation and are passed with the actual query to Collection::query() method; they can be empty if the default behavior is sufficient.

Methods

impl QueryHints[src]

pub fn new() -> QueryHints[src]

Creates a new, empty query hints set.

pub fn max(self, n: i64) -> QueryHints[src]

Sets the maximum number of entries which should be returned by the query.

Corresponds to $max hint in EJDB query hints syntax.

pub fn skip(self, n: i64) -> QueryHints[src]

Sets the number of entries which should be skipped first when query results are inspected.

Corresponds to $skip hint in EJDB query hints syntax.

pub fn order_by<S: Into<String>>(self, field: S) -> QueryHintsOrderBy[src]

Returns a builder for ordering hint for the provided field.

Corresponds to $orderBy hint in EJDB query hints syntax.

pub fn field<S: Into<String>>(self, field: S) -> QueryHintsField[src]

Returns a builder for setting inclusion/exclusion flag of the provided field.

Corresponds to $fields hint in EJDB query syntax.

pub fn into_bson(self) -> Document[src]

Converts these hints to a BSON document.

pub fn as_bson(&self) -> &Document[src]

Returns a reference to these hints as a BSON document.

pub fn as_bson_mut(&mut self) -> &mut Document[src]

Returns a mutable reference to these hints as a BSON document.

Be careful when modifying the document directly because it may lead to invalid hints.

Trait Implementations

impl PartialEq<QueryHints> for QueryHints[src]

impl Clone for QueryHints[src]

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

Performs copy-assignment from source. Read more

impl From<OrderedDocument> for QueryHints[src]

impl Into<OrderedDocument> for QueryHints[src]

impl Debug for QueryHints[src]

impl DerefMut for QueryHints[src]

impl Deref for QueryHints[src]

type Target = Document

The resulting type after dereferencing.

Auto Trait Implementations

impl Send for QueryHints

impl Sync for QueryHints

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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