[][src]Trait roa_diesel::preload::SqlQuery

pub trait SqlQuery<Conn: 'static + Connection> {
#[must_use]    fn execute<'life0, 'async_trait, E>(
        &'life0 self,
        exec: E
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
    where
        E: 'static + Send + ExecuteDsl<Conn>,
        E: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn load_data<'life0, 'async_trait, U, Q>(
        &'life0 self,
        query: Q
    ) -> Pin<Box<dyn Future<Output = Result<Vec<U>>> + Send + 'async_trait>>
    where
        U: 'static + Send,
        Q: 'static + Send + LoadQuery<Conn, U>,
        U: 'async_trait,
        Q: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn get_result<'life0, 'async_trait, U, Q>(
        &'life0 self,
        query: Q
    ) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>>
    where
        U: 'static + Send,
        Q: 'static + Send + LoadQuery<Conn, U>,
        U: 'async_trait,
        Q: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn get_results<'life0, 'async_trait, U, Q>(
        &'life0 self,
        query: Q
    ) -> Pin<Box<dyn Future<Output = Result<Vec<U>>> + Send + 'async_trait>>
    where
        U: 'static + Send,
        Q: 'static + Send + LoadQuery<Conn, U>,
        U: 'async_trait,
        Q: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn first<'life0, 'async_trait, U, Q>(
        &'life0 self,
        query: Q
    ) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>>
    where
        U: 'static + Send,
        Q: 'static + Send + LimitDsl,
        Limit<Q>: LoadQuery<Conn, U>,
        U: 'async_trait,
        Q: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
; }

A context extension to execute diesel dsl asynchronously.

Required methods

#[must_use]fn execute<'life0, 'async_trait, E>(
    &'life0 self,
    exec: E
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where
    E: 'static + Send + ExecuteDsl<Conn>,
    E: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

Executes the given command, returning the number of rows affected.

execute is usually used in conjunction with insert_into, update and delete where the number of affected rows is often enough information.

When asking the database to return data from a query, load should probably be used instead.

#[must_use]fn load_data<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Vec<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

Executes the given query, returning a Vec with the returned rows.

When using the query builder, the return type can be a tuple of the values, or a struct which implements Queryable.

When this method is called on sql_query, the return type can only be a struct which implements QueryableByName

For insert, update, and delete operations where only a count of affected is needed, execute should be used instead.

#[must_use]fn get_result<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

Runs the command, and returns the affected row.

Err(NotFound) will be returned if the query affected 0 rows. You can call .optional() on the result of this if the command was optional to get back a Result<Option<U>>

When this method is called on an insert, update, or delete statement, it will implicitly add a RETURNING * to the query, unless a returning clause was already specified.

#[must_use]fn get_results<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Vec<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

Runs the command, returning an Vec with the affected rows.

This method is an alias for load, but with a name that makes more sense for insert, update, and delete statements.

#[must_use]fn first<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LimitDsl,
    Limit<Q>: LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

Attempts to load a single record.

This method is equivalent to .limit(1).get_result()

Returns Ok(record) if found, and Err(NotFound) if no results are returned. If the query truly is optional, you can call .optional() on the result of this to get a Result<Option<U>>.

Loading content...

Implementations on Foreign Types

impl<S, Conn> SqlQuery<Conn> for Context<S> where
    S: State + AsRef<Pool<Conn>>,
    Conn: 'static + Connection
[src]

fn load_data<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Vec<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Executes the given query, returning a Vec with the returned rows.

When using the query builder, the return type can be a tuple of the values, or a struct which implements Queryable.

When this method is called on sql_query, the return type can only be a struct which implements QueryableByName

For insert, update, and delete operations where only a count of affected is needed, execute should be used instead.

fn get_result<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Runs the command, and returns the affected row.

Err(NotFound) will be returned if the query affected 0 rows. You can call .optional() on the result of this if the command was optional to get back a Result<Option<U>>

When this method is called on an insert, update, or delete statement, it will implicitly add a RETURNING * to the query, unless a returning clause was already specified.

fn get_results<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Vec<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Runs the command, returning an Vec with the affected rows.

This method is an alias for load, but with a name that makes more sense for insert, update, and delete statements.

fn first<'life0, 'async_trait, U, Q>(
    &'life0 self,
    query: Q
) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>> where
    U: 'static + Send,
    Q: 'static + Send + LimitDsl,
    Limit<Q>: LoadQuery<Conn, U>,
    U: 'async_trait,
    Q: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Attempts to load a single record.

This method is equivalent to .limit(1).get_result()

Returns Ok(record) if found, and Err(NotFound) if no results are returned. If the query truly is optional, you can call .optional() on the result of this to get a Result<Option<U>>.

Loading content...

Implementors

Loading content...