Struct aragog::query::JsonQueryResult[][src]

pub struct JsonQueryResult {
    pub documents: Vec<Value>,
    // some fields omitted
}

Result of a succeeded Query. Contains a Vec of serde_json::Value. The structure has methods to retrieve typed models (get_records).

Fields

documents: Vec<Value>

Vector of the returned documents

Implementations

impl JsonQueryResult[src]

pub fn new(documents: Vec<Value>) -> Self[src]

Instantiates a new JsonQueryResult from a document collection

pub fn get_records<T: Record>(&self) -> Vec<DatabaseRecord<T>>[src]

Retrieves deserialized documents from the json results. The documents not matching T will not be returned.

Example

If you want to do a graph query that can return different models you can use this method to retrieve the serialized record:

let json_results = Query::outbound(1, 5, "ChildOf", "User/123").call(&db_accessor).await.unwrap();

let user_results = json_results.get_records::<User>();
let topic_results = json_results.get_records::<Topic>();
let role_results = json_results.get_records::<Role>();

pub fn len(&self) -> usize[src]

Returns the length of documents

pub fn is_empty(&self) -> bool[src]

Returns true if no documents were returned

Trait Implementations

impl Debug for JsonQueryResult[src]

impl<T: Record> From<JsonQueryResult> for RecordQueryResult<T>[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, 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.